springboot支持模板引擎和JSP两种方式渲染前端页面。虽然支持JSP,但不建议使用。下面分别对两种方式进行介绍。
1.模板引擎方式
springboot(5.1.5)默认支持的模板引擎有:
- FreeMarker
- Groovy
- Thymeleaf
- Mustache
- velocity springboot1.4以前才支持,1.5后就不支持了
示例仅说明FreeMarker和Thymeleaf,其他可类似使用。
说明:静态资源放在/resources/static下面,模板文件放在/resources/template下面。
FreeMarker
!!!!这个不知道为啥就是无法找到页面,改成后面的thymeleaf就可以。
0.添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-