SpringBoot入门-14(springboot配置thymeleaf使用YML)
一 pom.xml
4.0.0
com.fs
springboot_thymeleaf_9_1
war
1.0-SNAPSHOT
springboot_thymeleaf_9_1 Maven Webapp
http://maven.apache.org
org.springframework.boot
spring-boot-starter-parent
1.5.3.RELEASE
1.5.3.RELEASE
4.12
UTF-8
1.7
org.springframework.boot
spring-boot-starter-thymeleaf
junit
junit
${junit-version}
test
org.springframework.boot
spring-boot-devtools
true
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-freemarker
junit
junit
test
springboot_thymeleaf_9_1
org.apache.maven.plugins
maven-compiler-plugin
1.7
1.7
org.springframework.boot
spring-boot-maven-plugin
二、SampleWebThymeleaf3Application.java
package com.fs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SampleWebThymeleaf3Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleWebThymeleaf3Application.class, args);
}
}
三、ThymeleafController.java
package com.fs.controller;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/")
public class ThymeleafController {
@RequestMapping("/index")
public String index(Map map){
map.put("user", "Tyrone");
return "index";
}
}
四、application.yml
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
content-type: text/html
mode: HTML5
五、index.html
Insert title here
Hello!!
welcom to Thymeleaf's world