Announcement Announcement Module
No announcement yet.
How to use VelocityLayoutViewResolver Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use VelocityLayoutViewResolver

    I have defined velocityConfig & viewResolver in applicationContext.xml file:

    <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
            <property name="resourceLoaderPath" value="/WEB-INF/velocity/"/>
            <!--<property name="configLocation" value="/WEB-INF/conf/velocity/"/>-->
          View resolvers can also be configured with ResourceBundles or XML files. If you need
          different view resolving based on Locale, you have to use the resource bundle resolver.
        <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
            <property name="cache" value="true"/>
            <property name="prefix" value="/WEB-INF/velocity/template/"/>
            <property name="suffix" value=".vm"/>
            <property name="contentType" value="text/html;charset=UTF-8"/>
            <property name="layoutUrl" value="/WEB-INF/velocity/layout/layout.vm"/>
            <!-- if you want to use the Spring Velocity macros, set this property to true -->
            <property name="exposeSpringMacroHelpers" value="true"/>
            <property name="exposeRequestAttributes" value="true"/>
            <property name="exposeSessionAttributes" value="true"/>
            <!--if you want to export request to vm.-->
            <!--<property name="exposeRequestAttributes" value="true"/>-->
            <!--If you want to export session to vm.-->
            <!--<property name="exposeSessionAttributes" value="true"/>-->
            <property name="viewClass" value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
    My question is :
    - How I can define layout.vm file? I can't find sample anywhere on the net.
    - If I return ModelAndView as "index", how I can handle this? Does all presentation will go through layout.vm? If so, how about if I want to have different layout for different functions?
    - Anyone have detailed material or example .

    I have searched online for almost 4 hours, but just got a little, please help.

    Thanks very much.

  • #2
    Anyone, please help...