在Spring 3.0.3中使用Velocity Tools


问题内容

当我更新bean时:

<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
  <property name="cache" value="true"/>
  <property name="prefix" value=""/>
  <property name="suffix" value=".vm"/>
  <property name="toolboxConfigLocation" value="tools.xml" />
</bean>

使用Velocity Tools的tools.xml路径,我得到:

Caused by: 
java.lang.ClassNotFoundException: org.apache.velocity.tools.view.ToolboxManager

我尝试插入工具版本2和1.4,但都没有此程序包结构。我错过了明显的事情吗?Spring / Velocity组件支持什么版本的Velocity Tools?


问题答案:

Spring默认情况下对Velocity的支持非常过时。我VelocityView从Spring
扩展了类并重写了createVelocityContext我自己初始化Tools的方法。是最后的样子。