Announcement Announcement Module
No announcement yet.
Struts/Velocity setup confusion Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Struts/Velocity setup confusion

    I am new to spring so I am not quite sure how all the pieces fit so here is my problem:

    I am writing struts app and I need to be able to use Velocity for views.

    my spring config file:

    <bean id="velocityEngine" singleton="true" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean">
    <property name="velocityPropertiesMap">
    <entry key="resource.loader">
    <value>ds, class</value>

    <entry key="class.resource.loader.class">
    <value>org.apache.velocity.runtime.resource.loader .ClasspathResourceLoader</value>

    <entry key="ds.resource.loader.instance">
    <ref bean="templateLoader"/>
    <entry key="ds.resource.loader.resource.table">
    <entry key="ds.resource.loader.resource.keycolumn">
    <entry key="ds.resource.loader.resource.templatecolumn">
    <entry key="ds.resource.loader.resource.timestampcolumn">

    <bean id="templateLoader" singleton="true" class="org.apache.velocity.runtime.resource.loader .DataSourceResourceLoader">
    <property name="dataSource">
    <ref local="dataSource"/>

    <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer">
    <property name="velocityEngine">
    <ref local="velocityEngine" />

    Now...should I use VelocityViewServlet(i'll have to configure everything again) or can I use VelocityViewResolver?

    <bean id="viewResolver" class="org.springframework.web.servlet.view.veloci ty.VelocityViewResolver">
    <property name="suffix">
    <property name="toolboxConfigLocation">
    <property name="exposeRequestAttributes">

    If I use VelocityViewResolver what additional components do I need to configure?

  • #2
    Basically, Struts forward to a view processor. That is, if you want to use Velocity, you should configure VelocityViewServlet in your web.xml
    For more information on using/configuring Struts with Spring, please review Chapter 15. Integrating with other web frameworks.

    Hope this helps.


    • #3
      I got struts to play nice with spring - my problem is velocity. I already have Velocity Engine configured in spring and I would like to reuse that configuration (see my configs above). If I configure VelocityVewServlet in web.xml I will have to configure another Velocity engine.