第一步:先在pom.xml加入thymeleaf和shiro的依赖
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.2.1</version>
</dependency>
第二步:在ShiroConfig写入一个bean
@Bean public ShiroDialect shiroDialect() { return new ShiroDialect(); }
第三步:在html中加入xmlns
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
第四步:在相应的标记那里添加shiro
<li><a shiro:hasPermission="sys:user:user" data-href="admin_list.html" data-title="用户管理" href="javascript:void(0)">用户管理</a></li>
<li><a shiro:hasPermission="sys:role:role" data-href="admin_role.html" data-title="角色管理" href="javascript:void(0)">角色管理</a></li>