zoukankan      html  css  js  c++  java
  • 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来自:

  • 相关阅读:
    NOIP模拟测试17
    C++11下的关键字
    Tyvj 1518 CPU监控(线段树)
    单身三连之三
    论求解线性方程
    单身三连之二
    单身三连之一
    20190719总结
    卡常
    论突变为零(不定更新)
  • 原文地址:https://www.cnblogs.com/leeego-123/p/11567035.html
Copyright © 2011-2022 走看看