SpringBoot集成velocity

pom.xmlhtml

<!-- 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.propertiesspring

# 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.xmlapp

<?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

相關文章
相關標籤/搜索