首先命名空间问题
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
//或者是xmlns:sec="http://www.w3.org/1999/xhtml"
一定要记得看清楚sec和th。
第二个问题可能是导入依赖的版本号没有相互对应
<dependency>
<groupId>org.thymeleaf.extras