您的位置:首页 > 编程语言 > Java开发

SpringBoot集成velocity

2016-08-27 00:00 330 查看
摘要: SpringBoot集成velocity

pom.xml

<!-- thymeleaf是spring的默认主题 -->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
-->

<!-- 默认配置下spring boot会从src/main/resources/templates目录中去找模板 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>


application.properties

# VELOCITY TEMPLATES (VelocityAutoConfiguration)
spring.velocity.resourceLoaderPath=classpath:/templates/
#spring.velocity.suffix=.html
spring.velocity.suffix=.vm
spring.velocity.toolbox-config-location=toolbox.xml
spring.velocity.charset=UTF-8
spring.velocity.properties.input.encoding=UTF-8
spring.velocity.properties.output.encoding=UTF-8


toolbox.xml

<?xml version="1.0"?>
<toolbox>
<tool>
<key>velocityTool</key>
<scope>application</scope>
<class>cn.no7player.util.VelocityTool</class>
</tool>
</toolbox>


页面调用方式:
<td>$!velocityTool.getFormatTime($dateTime)</td>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Spring Boot velocity