1.1. 导入thymeleaf扩展坐标 ``
1.2. 配置ShiroDialect 在ShiroConfig类里面添加getShiroDialect方法
/**
- 配置ShiroDialect,用于thymeleaf和shiro标签配合使用
*/ `` @Bean
public ShiroDialect getShiroDialect(){
return new ShiroDialect();
} `` 1.3. 在页面上使用shiro标签
`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>测试Thymeleaf的使用</title>
</head>
<body>
<h3 th:text="${name}"></h3>
<hr/>
<div shiro:hasPermission="user:add">
进入用户添加功能: <a href="add">用户添加</a><br/>
</div>
<div shiro:hasPermission="user:update">
进入用户更新功能: <a href="update">用户更新</a><br/>
</div>
<a href="toLogin">登录</a>
</body>
</html>`
over
注意:本文归作者所有,未经作者允许,不得转载