【springboot shiro】(6)thymeleaf和shiro标签整合使用

1.1. 导入thymeleaf扩展坐标 ``

com.github.theborakompanioni

thymeleaf-extras-shiro

2.0.0

``

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


已有 0 条评论

    欢迎您,新朋友,感谢参与互动!