这篇博客只是随便记录一下,方便以后自己查看(主要配置toolbox.xml、velocity.properties加载):
1.struts中配置:struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.velocity.toolboxlocation" value="WEB-INF/classes/config/velocity/toolbox.xml" /> <constant name="struts.velocity.configfile" value="WEB-INF/classes/config/velocity/velocity.properties" /> <constant name="struts.velocity.manager.classname" value="org.apache.struts2.views.velocity.VelocityManager" /> </struts>
2.spring中配置:
<!-- velocity配置 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="contentType"> <value>text/html;charset=UTF-8</value> </property> <property name="layoutUrl" value="layout/Default.vm" /> <property name="toolboxConfigLocation" value="WEB-INF/classes/config/velocity/toolbox.xml" /> </bean> <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="configLocation" value="WEB-INF/classes/config/velocity/velocity.properties"/> </bean>