springboot与shiro在html中使用shiro标签

上一章讲环境搭建

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

转载于:https://www.cnblogs.com/xiaostudy/p/10991073.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值