您需要在项目中添加Spring Security 3集成模块。这些模块是Thymeleaf的方言,等同于Spring安全标签lib。这些是百里香额外的模块,不是百里香核心的一部分。
在您的模板引擎中,只需添加集成模块方言即可。
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
...
<property name="additionalDialects">
<set>
<bean class="org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect"/>
</set>
</property>
...
</bean>
<div sec:authentication="name">The value of the "name" property of
the authentication object should appear here.</div>
Thymeleaf等效模块可在此处找到。另外,请参考他们的这个逐步教程
更新: