Jsp在内嵌的servlet容器上运行有一些问题(内嵌tomcat、jetty不支持以jar形式运行jsp,undertow不支持jsp)
Spring boot提供了大量模板引擎,包含FreeMarker、Groovy、Thymeleaf、Velocity和Mustache,springBoot推荐使用Thymeleaf作为模板引擎,因为Thymeleaf提供了完美的springMVC支持。
1.添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.添加controller
和jsp的没什么两样
@RequestMapping("/toLogin")
public String toLogin(){