shrio学习笔记

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来自:

 

posted @ 2019-09-22 12:52  不死码农  阅读(219)  评论(0编辑  收藏  举报