这是spring.xml的配置文件,

<!--使用thyme leaf--><!--视图解析器--><bean id="templateResolver" class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver"><property name="prefix" value="/"></property><property name="suffix" value=".html"></property><property name="templateMode" value="HTML"></property><property name="cacheable" value="false"/><property name="characterEncoding" value="UTF-8"/></bean><bean id="templateEngine" class="org.thymeleaf.spring5.SpringTemplateEngine"><property name="templateResolver" ref="templateResolver"></property><property name="additionalDialects"><set><!--方言解释器--><bean class="at.pollux.thymeleaf.shiro.dialect.ShiroDialect"/></set></property></bean><bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver"><property name="templateEngine" ref="templateEngine"/><property name="characterEncoding" value="UTF-8"/></bean>

这是pom.xml

 <!--Shiro--><!--集成spring--><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId><version>1.7.1</version></dependency><!--web项目--><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-web</artifactId><version>1.7.1</version></dependency><!--shiro日志--><!-- shiro  --><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-all</artifactId><version>1.7.1</version></dependency><!-- 引入ehcache的依赖,给shiro做缓存权限用的 --><dependency><groupId>net.sf.ehcache</groupId><artifactId>ehcache</artifactId><version>2.10.6</version></dependency><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-core</artifactId><version>1.4.1</version></dependency><!-- Shiro uses SLF4J for logging.  We'll use the 'simple' bindingin this example app.  See http://www.slf4j.org for more info. --><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId><version>1.7.21</version><scope>compile</scope></dependency><dependency><groupId>org.slf4j</groupId><artifactId>jcl-over-slf4j</artifactId><version>1.7.21</version><scope>compile</scope></dependency><dependency><groupId>org.thymeleaf</groupId><artifactId>thymeleaf</artifactId><version>3.0.10.RELEASE</version></dependency><dependency><groupId>org.thymeleaf</groupId><artifactId>thymeleaf-spring5</artifactId><version>3.0.10.RELEASE</version></dependency><dependency><groupId>com.github.theborakompanioni</groupId><artifactId>thymeleaf-extras-shiro</artifactId><version>2.0.0</version></dependency><dependency><groupId>org.attoparser</groupId><artifactId>attoparser</artifactId><version>2.0.0.RELEASE</version></dependency>

以下是html

<html lang="en" xmlns:th="http://www.thymeleaf.org"xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"><head><meta charset="UTF-8"><title>index</title>
</head>
<body><h1>index</h1>
<a  href="/logout">logout</a>
<br><br><a href="common.html">一般用户</a>
<a href="admin.html">管理员</a><p shiro:hasRole="admin">
你好 管理员!
</p>
<a shiro:hasRole="user">你好user</a>
<a href="/shiroTest">测试时间</a></body>
</html>

普通用户登录


显示你好user

=====================================

管理员登录、


显示你好管理员,

html 使用shiro标签 thymeleaf相关推荐

  1. 【thymeleaf 】在 thymeleaf 中使用 shiro 标签

    前言 sprint boot 2.3.4.RELEASE 说明 shiro 未提供对 thymeleaf 的支持.第三方项目 thymeleaf-extras-shiro 提供了在 thymeleaf ...

  2. springboot+thymeleaf+shiro标签

    1,pom中加入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId&g ...

  3. thymeleaf模板+Shiro标签对按钮权限的控制

    thymeleaf模板+Shiro标签对按钮权限的控制 环境介绍 SpringBoot+Shiro+thymeleaf模板+Layui(前端) 这两天学习了shiro相关的技术,碰到一个问题:如何根据 ...

  4. Spring Boot Thymeleaf中使用Shiro标签

    在<Spring-Boot-shiro权限控制>中,当用户访问没有权限的资源时,我们采取的做法是跳转到403页面,但在实际项目中更为常见的做法是只显示当前用户拥有访问权限的资源链接.配合T ...

  5. springboot2 + thymeleaf + shiro1.4+redis里前端shiro标签没法用

    自打用了shiro,项目是三天两头出BUG...同样的配置摆在我这就不成...心痛 如今遇到了个更奇怪的问题,是前后端耦合的项目,直接调Index.html里的登陆接口可以实现登陆,但加上shiro标 ...

  6. Shiro快速入门 —— 9.freemaker使用shiro标签

    2019独角兽企业重金招聘Python工程师标准>>> 本系列博文目录:https://my.oschina.net/u/3452433/blog/907396 shiro-free ...

  7. js中使用shiro标签的一个小坑

    在jsp页面中使用shiro标签很简单 <shiro:haspermission name="你的权限"> 你的标签 </shiro:haspermission& ...

  8. 请教Nutzwk项目,在beetl页面怎么用shiro标签呢?

    请教Nutzwk项目,在beetl页面怎么用shiro标签呢? 发布于 381天前  作者 WenTao-Love  195 次浏览  复制  上一个帖子  下一个帖子  标签: nutzwk 如题, ...

  9. 第九节 Shiro标签原理分析

    一.shiro的标签 首先,你需要知道的是,标签的实质其实是Java代码.你已经知道,JSP实质也是Java代码,更别说用在JSP中的标签了. 稍后你会在源码追踪环节了解到:Shiro标签执行了哪些J ...

最新文章

  1. 网站开发流程以及HTML5简介(三)
  2. mysql优化Analyze Table
  3. Javascript 未结束的字符串常量
  4. Linux运维工程师必备技能
  5. Ubuntu 安装LAMP ...
  6. getElementById()方法取值
  7. ios10不能定位 window.navigator.geolocation.getCurrentPosition(定位第一节)
  8. iOS网络层架构设计分享
  9. 【转】mybatis在xml文件中处理大于号小于号的方法
  10. 廖雪峰的Python总结
  11. 2022年京东年货节红包雨攻略,年货节红包最高领8888元红包
  12. 70行代码让你远离颈椎病,致所有的程序猿们
  13. IDEA做数据库操作时的一个莫名其妙的错误
  14. Spring Boot使用@RepeatSubmit 防止重复提交
  15. stm32用python编程_使用 Python 来开发 STM32F411 !
  16. Oracle数据库服务
  17. python井字棋代码_python井字棋算法及代码
  18. 计算机网络在财务管理中的运用,浅析如何应用计算机网络进行财务管理
  19. 计算机科学与技术是英语一码,“计算机科学与技术专业本科课程”的英文翻译是什么?...
  20. 卸载CUDA10.1,安装CUDA10.0

热门文章

  1. July深度学习之RNN循环神经网络
  2. Python实现raw文件批量转tif/png/jpg
  3. 深谙避税技巧的超级企业:谷歌苹果微软在列
  4. 酒泉春光农产品市场有限责任公司董事长李江元
  5. Ubuntu之ld搜索路径顺序
  6. APICloud AVM框架 开发企业OA办公项目
  7. Android6.0 mtk去除原生相机设置中的选项
  8. 计算机学生是否有必要考研?学历对程序员的影响到底有多大?
  9. 基于flask+vue前后端分离 一款简单的旅游网站源码,带admin管理系统
  10. 苏州超级计算机叫什么,苏州超级计算机中心正式投用 助力长三角算力资源互联...