1.在pom.xml中添加依赖
org.apache.velocity
velocity
1.7
org.apache.velocity
velocity-tools
2.0
2.从velocity-tools-2.0.jar的org.apache.velocity.tools.view包中复制出velocity.properties和tools.xml文件
到WEB-INF目录下,修改velocity.properties:
input.encoding=UTF-8
output.encoding=UTF-8
3.配置web.xml文件中的servlet
velocity
org.apache.velocity.tools.view.servlet.VelocityViewServlet
org.apache.velocity.properties
/WEB-INF/velocity.properties
org.apache.velocity.toolbox
/WEB-INF/tools.xml
velocity
*.vm