Spring boot 使用freemarker模板
2017-10-23 09:51
477 查看
在pom文件引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
关闭freemarker缓存
########################################################
###FREEMARKER (FreeMarkerAutoConfiguration)
########################################################
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
#spring.freemarker.prefix=
#spring.freemarker.request-context-attribute=
#spring.freemarker.settings.*=
#spring.freemarker.suffix=.ftl
#spring.freemarker.template-loader-path=classpath:/templates/ #comma-separated list
#spring.freemarker.view-names= # whitelist of view names that can be resolved
编写模板文件.ftl
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello.v.2</h1>
<p>${hello}</p>
</body>
</html>
编写访问文件的controller
@RequestMapping("/helloFtl")
public String helloFtl(Map<String,Object> map){
map.put("hello","from TemplateController.helloFtl");
return "/helloFtl";
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
关闭freemarker缓存
########################################################
###FREEMARKER (FreeMarkerAutoConfiguration)
########################################################
spring.freemarker.allow-request-override=false
spring.freemarker.cache=true
spring.freemarker.check-template-location=true
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=false
#spring.freemarker.prefix=
#spring.freemarker.request-context-attribute=
#spring.freemarker.settings.*=
#spring.freemarker.suffix=.ftl
#spring.freemarker.template-loader-path=classpath:/templates/ #comma-separated list
#spring.freemarker.view-names= # whitelist of view names that can be resolved
编写模板文件.ftl
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello.v.2</h1>
<p>${hello}</p>
</body>
</html>
编写访问文件的controller
@RequestMapping("/helloFtl")
public String helloFtl(Map<String,Object> map){
map.put("hello","from TemplateController.helloFtl");
return "/helloFtl";
}
相关文章推荐
- (18)使用模板(thymeleaf-freemarker)【从零开始学Spring Boot】
- (9) spring boot使用freemarker模板引擎
- Spring Boot 与 Kotlin使用Freemarker模板引擎渲染web视图
- Spring Boot使用模板freemarker的示例代码
- (18)使用模板(thymeleaf-freemarker)【从零开始学Spring Boot】
- Spring Boot使用模板freemarker【从零开始学Spring Boot(转)
- (18)使用模板(thymeleaf-freemarker)【从零开始学Spring Boot】
- spring boot 使用velocity、freeMarker模板创建html页面返回给前端
- spring boot 使用velocity、freeMarker模板创建html页面返回给前端
- springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用
- 93.Spring Boot使用模板freemarker【从零开始学Spring Boot】
- spring boot中使用FreeMarker模板
- 170703、springboot编程之模板使用(thymeleaf、freemarker)
- Spring boot 使用freemarker模板
- SpringBoot-07引擎模板thymeleaf和freemarker的使用
- 一头扎进springboot之使用Freemarker模板引擎渲染web视图
- springboot学习记录之 thymeleaf使用模板
- 深入学习spring-boot系列(三)--使用thymeleaf模板
- springboot 普通发送邮件 和 freemarker模板发送邮件
- Spring Boot 使用 Thymeleaf模板