這裏用的是 thymeleaf 2.x版本的html
添加依賴git
<dependency>
1.2.1<groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version></version>
</dependency>
在shiro的configuration中配置github
@Bean public ShiroDialect shiroDialect() { return new ShiroDialect(); }
在html中加入xmlnsspa
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
例子code
<span shiro:authenticated="true" > <span>歡迎您:<span th:text="${userInfo.realName}"></span></span> </span>