Announcement Announcement Module
Collapse
No announcement yet.
spring macro does not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring macro does not work

    Hi,
    I turn around nearly two days but the spring macro still does not work.
    I use Spring 1.2 on Linux
    For the config file servlet.xml, I have
    <bean id="viewResolverVelocity"
    class="org.springframework.web.servlet.view.Resour ceBundleViewResolver">
    <property name="basenames">
    <list>
    <value>views_velocity</value>
    <value>views_jsp</value>
    </list>

    </property>
    </bean>

    <bean id="velocityConfigurer"
    class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="resourceLoaderPath">
    <value>/</value>
    </property>
    <property name="velocityProperties">
    <props>
    <prop key="velocimacro.library">/common/macros.vm

    </props>
    </property>
    </bean>
    In this way the spring macro are not visible at all. So I copy spring.vm to the /common directory where I have my own macros.vm. In the VelocityConfigurer, I have to add /common/spring.vm as following:
    <property name="velocityProperties">
    <props>
    <prop key="velocimacro.library">/common/macros.vm, /common/spring.vm</props>
    </property>
    The spring macro are now active. In my velocity page:
    <form method="post" enctype="multipart/form-data">
    #springBind("fileForm.version")
    <input type="text" name="version" value="$!{fileForm.value}">

    and so on until I close the form by </form>

    The "fileForm" is the commandName defined in the config file servlet.xml.
    The input field does not return any value whereas <input type="text" name="version" value="$!{fileForm.version}" return the value. I am more convinced that there are problems anywhere with the configuration of spring macro in my application. I don't find a lots of samples or documents for Velocity in Spring.
    Thank in advance for any advice.

  • #2
    Error of writting

    I made a error while writting the problem:
    <input type="text" name="version" value="$!{fileForm.value}"> should be
    <input type="text" name="version" value="$!{status.value}">. And it does not return any value of fileForm.version backing object.

    Comment


    • #3
      This fixes your problem

      <bean id="velocityConfig"
      class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
      <property name="resourceLoaderPath" value="/WEB-INF/velocity/" />
      <property name="velocityProperties">
      <props>
      <prop key="velocimacro.library">org/springframework/web/servlet/view/velocity/spring.vm,VM_global_library.vm</prop>
      </props>
      </property>
      </bean>

      This config allows you to use the existing spring.vm macro in spring, and define your own macro file in /WEB-INF/velocity dir.

      Comment

      Working...
      X