zoukankan      html  css  js  c++  java
  • shiro整合thymeleaf

    1.引入依赖

    pom.xml2

    <!--thymeleaf中使用shiro-->
            <dependency>
                <groupId>com.github.theborakompanioni</groupId>
                <artifactId>thymeleaf-extras-shiro</artifactId>
                <version>2.0.0</version>
            </dependency>

    2.ShiroConfig编写shiroDialog

    @Bean(name = "shiroDialect")
        public ShiroDialect shiroDialect(){
            return new ShiroDialect();
        }

    3.在html中添加xmlns

    <html lang="en" xmlns:th="http://www.thymeleaf.org"
                    xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

    4.在标签中使用shiro

    <!DOCTYPE html>
    <html lang="en" xmlns:th="http://www.thymeleaf.org"
                    xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <!--从seesion中判断是否有用户-->
    <div th:if="${session.loginUser==null} ">
        <a th:href="@{/toLogin}">登陆</a>
    </div>
    <div th:if="${session.loginUser != null}">
        <a th:href="@{/logout}">注销</a>
    </div>
    <div shiro:hasPermission="user-add">
        <a th:href="@{/user/add}">add</a>
    </div>
    <div shiro:hasPermission="user-update">
        <a th:href="@{/user/update}">update</a>
    </div>
    </body>
    </html>
  • 相关阅读:
    ugui点击穿透判断
    c#字符串代码,动态创建编译器
    github项目分享
    unity 2d 版的lookAt
    unity全屏截图
    shader例子
    AcWing 329. 围栏障碍训练场
    AcWing 326. XOR和路径
    AcWing 324. 贿赂FIPA
    AcWing 322. 消木块
  • 原文地址:https://www.cnblogs.com/gaoyangliu/p/12833535.html
Copyright © 2011-2022 走看看