velocity
来源:互联网 发布:淘宝全民分享怎么设置 编辑:程序博客网 时间:2024/04/29 13:33
首先,在pom.xml中加入以下依赖:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
注意版本要正确,一开始就踩上坑了,,汗~
其次,在appcontext-serverlet.xml,这个可能命名会有所区别,加以下内容:
<beans:bean id="velocityConfigurer"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<beans:property name="resourceLoaderPath">
<beans:value>WEB-INF/vm/</beans:value> #这里的设置相当于有了prefix,所以在下面不用再设置
</beans:property>
<beans:property name="velocityProperties">
<beans:props>
<beans:prop key="input.encoding">UTF-8</beans:prop>
<beans:prop key="output.encoding">UTF-8</beans:prop>
<beans:prop key="eventhandler.referenceinsertion.class">org.apache.velocity.app.event.implement.EscapeHtmlReference</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<beans:property name="suffix" value=".vm" /> #这里不需要设置prefix
<beans:property name="contentType" value="text/html;charset=utf-8" />
</beans:bean>
ok,环境已配置好,就是写vm文件和相应的controller控制了
- Velocity
- Velocity
- Velocity
- Velocity
- Velocity
- Velocity
- velocity
- VELOCITY
- Velocity
- Velocity
- VELOCITY
- velocity
- Velocity
- VELOCITY
- Velocity
- Velocity
- Velocity
- Velocity
- 技术路线开始记录~
- 华为OJ(汽水瓶)
- uva 811 - The Fortified Forest(暴力+凸包)
- RESTful Java client with java.net.URL
- Android设置虚线、圆角、渐变
- velocity
- HDU4687 (一般图匹配)
- tslib移植
- ural 1109. Conference 匈牙利算法
- 树的基本概述
- 设置多行多列图标的循环体
- 【索引】Geometric Algorithms in 2D::Exercises: Beginner
- RESTful Java client with Apache HttpClient
- ffmpeg视频格式转化及flv格式截图