使用 spring 3.x 配置速度工具 [英] Configure velocity tools with spring 3.x

查看:27
本文介绍了使用 spring 3.x 配置速度工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对弹簧和速度都不熟悉我想用 spring 3.x 配置速度工具但我找不到关于它的好文章
+ 速度模板没有显示会话变量我从 Spring 控制器设置

I am new to both spring and velocity I want to configure velocity tools with spring 3.x but I could not find a good article on that
+ the velocity template is not showing the session variable I set from Spring controller

推荐答案

至于在 spring 3.x 中配置 Velocity 工具,首先将你的 tools.xml 文件放在有用的地方,例如:/WEB-INF/vm/toolbox.xml然后配置您的视图解析器以查看该位置:

As for configuring Velocity tools in spring 3.x, first put your tools.xml file somewhere useful, eg: /WEB-INF/vm/toolbox.xml THEN configure your view resovler to look in that place:

<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    ...
    <!--Other config properties in here -->
    ...
    <property name="toolboxConfigLocation" value="/WEB-INF/vm/toolbox.xml" />
</bean>

示例 toolbox.xml 文件:

An example toolbox.xml file:

<toolbox>
<xhtml>true</xhtml>
<tool>
    <key>date</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.DateTool</class>
    <parameter name="format" value="dd/MM/yyyy" />
</tool>
<tool>
    <key>display</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.DisplayTool</class>
</tool>
<tool>
    <key>math</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.MathTool</class>
</tool>
<tool>
    <key>iter</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.IteratorTool</class>
</tool>
<tool>
    <key>sort</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.SortTool</class>
</tool>
</toolbox>

希望这一点至少有所帮助.

Hope this bit helps, at least.

这篇关于使用 spring 3.x 配置速度工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆