当前位置: 首页 > article >正文

进阶SpringBoot之 Shiro(6)整合 Thymeleaf

Subject:用户

SecurityManager:管理所有用户

Realm:连接数据

pom.xml 导入 thymeleaf-extras-shiro 的 jar 包,整合 shiro-thymeleaf

        <!-- shiro-thymeleaf 整合 -->
        <dependency>
            <groupId>com.github.theborakompanioni</groupId>
            <artifactId>thymeleaf-extras-shiro</artifactId>
            <version>2.1.0</version>
        </dependency>

ShiroConfig 配置类:ShiroDialect

    //ShiroDialect:整合shiro-thymeleaf
    @Bean
    public ShiroDialect getShiroDialect(){
        return new ShiroDialect();
    }

index.html:

xmlns:shiro="http://www.thymeleaf.org/thymeleaf-extras-shiro"

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.thymeleaf.org/thymeleaf-extras-shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<shiro:guest>
<h1>首页</h1>
<p><a th:href="@{/toLogin}">登录</a></p>
<p th:text="${msg}"></p>
<hr>

<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>
</shiro:guest>

</body>
</html>

http://www.kler.cn/news/289372.html

相关文章:

  • 【word导出带图片】使用docxtemplater导出word,通知书形式的word
  • 0基础学习爬虫系列:Python环境搭建
  • Anaconda的环境管理操作命令详解-学习篇
  • mysql创建数据库和表
  • list的简单实现
  • springblade-JWT认证缺陷漏洞CVE-2021-44910
  • 4.1 数据分析-excel 基本操作
  • Java语言程序设计基础篇_编程练习题**17.21 (十六进制编辑器)
  • LinkedList与链表
  • Java基于微信小程序的实习管理系统
  • C++ 设计模式——中介者模式
  • Django 安装指南
  • notepad++软件介绍(含安装包)
  • 力扣56-合并区间(Java详细题解)
  • Electron 项目实战 02:打包和自动更新
  • Linux下的VLC简介
  • 语言桥梁:探索全球最受欢迎的翻译工具,让理解更简单
  • MySQL复习3
  • 计算机岗位(面试)
  • Apache POl的使用(导出报表)
  • Python Mail:如何设置SMTP服务器发邮件?
  • Java设计模式【观察者模式】-行为型
  • “微服务革命”之后...
  • 机器人外呼有哪些优势?
  • MFC终止线程实例
  • 性能工具之 JMeter ajax 简单登录案例实战
  • 二叉树(数据结构)
  • Elasticsearch 索引模板
  • 编译可执行命令的FFmpeg
  • [STM32]从零开始的STM32 LED教程(小白向)