shrio学习笔记

匿名 (未验证) 提交于 2019-12-03 00:11:01

Thymeleaf扩展坐标

      <!--thyemleaf对shrio的扩展坐标-->         <dependency>             <groupId>com.github.theborakompanioni</groupId>             <artifactId>thymeleaf-extras-shiro</artifactId>             <version>2.0.0</version>         </dependency>         

配置ShiroDialect

在ShiroConfig类里面添加getShiroDialect方法

/** *配置ShiroDialect,用于thymeleaf和shiro 标签配合使用 */  @Bean Public ShiroDialect getShiroDialect(){   return new ShiroDialect(); }

test.html文件

<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Title</title> </head> <body>     <div shiro:hasPermission="user:add">                 <a href="add">添加</a>     </div>     <div shiro:hasPermission="user:update">         <a href="add">更新</a>     </div> </body> </html>

效果:会根据shiro的用户资源来选择隐藏test.html中的添加或更新

 

这里的用户授权

 

 

这里的用户授权的User来自:

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!