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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM