如今講html中怎麼使用shiro標籤,這裏是基於上一章講的html
在pom文件引入依賴java
<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】mysql
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>
接着上一章的測試git
參考文章:https://blog.csdn.net/fox9916/article/details/80221894github