一、引入依赖
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>2.0.0</version>
</dependency>
二、在shiro的configuration中配置
@Bean
public ShiroDialect shiroDialect() {
return new ShiroDialect();
}
三、标签使用
1、加入html命名空间
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
2、加入shiro标签
<shiro:guest>
<a>登录</a> <a>注册</a>
</shiro:guest>
<shiro:user>
欢迎<shiro:principal property="name"/>
</shiro:user>