spring boot 与shiro实战(六)thymeleaf和shiro标签整合使用
2019-03-19 10:36
2271 查看
spring boot 与shiro实战(六)thymeleaf和shiro标签整合使用
本篇文章接自上一篇:spring boot 与shiro实战(五)整合实现用户授权
https://blog.csdn.net/jingjingxiazhe/article/details/88638984
源码git地址:https://gitee.com/maximusrj/springboot-shiro.git
内附表的sql语句,以及黑马shiro的视频和源码以及笔记
1.1导入thymeleaf扩展坐标
在pom.xml文件中添加
<!-- thymel对shiro的扩展坐标 --> <dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>2.0.0</version> </dependency>
1.2配置ShiroDialect
在ShiroConfig类里面添加getShiroDialect方法
/** * 配置ShiroDialect,用于thymeleaf和shiro标签配合使用 */ @Bean public ShiroDialect getShiroDialect(){ return new ShiroDialect(); }
1.3在页面上使用shiro标签
修改test.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>测试Thymeleaf的使用</title> </head> <body> <h3 th:text="${name}"></h3> <hr/> <div shiro:hasPermission="user:add"> 进入用户添加功能: <a href="add">用户添加</a><br/> </div> <div shiro:hasPermission="user:update"> 进入用户更新功能: <a href="update">用户更新</a><br/> </div> <a href="toLogin">登录</a> </body> </html>
最后在pom.xml文件中添加如下的版本控制,不然的话会报java.lang.NoClassDefFoundError的错误:
<properties> <thymeleaf.version>3.0.3.RELEASE</thymeleaf.version> <thymeleaf-layout-dialect.version>2.2.0</thymeleaf-layout-dialect.version> </properties>
最后进行测试,运行启动类,打开登录界面:http://localhost:8080/toLogin
輸入用户名eric 密码123456,则跳转到只显示用户添加权限的界面:
輸入用户名jack 密码123456,则跳转到只显示用户添加更新权限的界面:
项目整体结构:
源码git地址:https://gitee.com/maximusrj/springboot-shiro.git
内附表的sql语句,以及黑马shiro的视频和源码以及笔记
相关文章推荐
- Spring Boot整合thymeleaf使用、thymeleaf常用标签、thymeleaf常用语法
- springboot+shiro实现登录系数限定,thymeleaf中使用shiro标签
- springboot thymeleaf和shiro标签整合
- springboot 在ftl页面上使用shiro标签的实例代码
- springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用
- springboot 2.0 集成 shiro 和 thymeleaf-extras-shiro 2.0 使用过程遇到的问题
- spring mvc + shiro +thymeleaf 扩展使用shiro tags页面标签
- SpringBoot学习:整合shiro(身份认证和权限认证),使用EhCache缓存
- Spring Boot Shiro 权限信息缓存处理,记住我,thymleaf使用shiro标签
- Apache Shiro 整合Spring 进行权限验证 以及在Freemarker中使用shiro标签
- Spring boot使用Thymeleaf模板的时候标签未关闭报错解决
- Spring boot项目整合thymeleaf和shiro
- 使用myeclipse搭建SpringBoot框架,整合thymeleaf模板和mybatis
- springboot thymeleaf和shiro 整合——按钮可见性
- springboot项目,thymeleaf整合shiro
- thymeleaf :springboot整合mybatis的web项目中使用html而不是jsp当页面渲染
- Apache Shiro 整合Spring 进行权限验证 以及在Freemarker中使用shiro标签
- spring boot 使用thymeleaf 和shiro标签整合
- springboot 继承shiro 使用redis缓存 @Value 标签无效 无法获取值