首页 > 编程语言 > 详细

springboot与shiro在html中使用shiro标签

时间:2019-06-08 17:07:14      阅读:788      评论:0      收藏:0      [点我收藏+]

上一章讲环境搭建

springboot与shiro和mybatis和mysql

 

现在讲html中怎么使用shiro标签,这里是基于上一章讲的

在pom文件引入依赖

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

技术分享图片

 

shiro的配置类ShiroConfig.java添加bean【at.pollux.thymeleaf.shiro.dialect.ShiroDialect】

1 @Bean
2 public ShiroDialect shiroDialect() {
3     return new ShiroDialect();
4 }

技术分享图片

 1 <!DOCTYPE html>
 2 <html lang="en" xmlns:th="http://www.thymeleaf.org"
 3       xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 4 
 5 <head>
 6     <title>首页</title>
 7 </head>
 8 <body>
 9 <h1>首页</h1>
10 <hr>
11 <ul>
12     <li><a href="user/index">个人中心</a></li>
13     <li><a href="vip/index">会员中心</a></li>
14     <p shiro:hasPermission="svip"><li>这是svip能看到的p标签</li></p>
15     <shiro:hasPermission name="svip"><li>这是svip能看到的</li></shiro:hasPermission>
16     <li><a href="logout">退出登录</a></li>
17 </ul>
18 </body>
19 </html>

 

接着上一章的测试

技术分享图片

技术分享图片

技术分享图片

技术分享图片

 

参考文章:https://blog.csdn.net/fox9916/article/details/80221894

springboot与shiro在html中使用shiro标签

原文:https://www.cnblogs.com/xiaostudy/p/10991073.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!