javascript
Spring Boot 13 之freemarker
2019独角兽企业重金招聘Python工程师标准>>>
1、加入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
2、在application.properties下加入配置
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
3、编写controller
/**
* 返回模板.
*/
@RequestMapping("/helloFtl")
public String helloFtl(Map<String,Object> map){
map.put("hello","from TemplateController.helloFtl");
return"/helloFtl";
}
4、在 src/main/resources/templates下加入模板。
src/main/resouces/templates/helloFtl.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>
转载于:https://my.oschina.net/huaForever/blog/807165
总结
以上是生活随笔为你收集整理的Spring Boot 13 之freemarker的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: css3多行超出隐藏并打点点
- 下一篇: 前进的2016