thymeleaf
模板引擎 thymeleaf, freemarker, velocity 等都是 jsp 的替代品。thymeleaf 是 springboot 官方推荐的。
sec:authentication="name" 不起作用
pom 使用的如下配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
发现可能是 thymeleaf 方言拓展的版本问题,但改成 thymeleaf-extras-springsecurity6 依然不起作用,无意中改了一下项目配置 application.properties,关掉了 thymeleaf 的缓存居然就正常了,配置如下:
#thymeleaf 配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
#缓存设置为false, 这样修改之后马上生效,便于调试
spring.thymeleaf.cache=false