学习笔记 : Thymeleaf整合Shiro标签
详情请参考 : 一个简单的SpringBoot整合Shiro的权限管理案例
引入依赖
添加Thymeleaf及其对Shiro扩展的依赖1
2
3
4
5
6
7
8
9
10
11<!-- Thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Thymeleaf对shiro的扩展 -->
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>2.0.0</version>
</dependency>
配置
在Shiro的配置类中配置ShiroDialect
1
2
3
4
5
6
7
8
9 /**
* @description: 配置ShiroDialect, 用于thymeleaf和shiro标签配合使用
* @date: 2019-08-05 6:37 PM
* @return: at.pollux.thymeleaf.shiro.dialect.ShiroDialect
*/
public ShiroDialect shiroDialect() {
return new ShiroDialect();
}
添加HTML命令空间
1 | <html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> |
Thymealf+Shiro标签
1 | <!-- guest标签:用户没有身份验证时显示相应信息,即游客访问信息 --> |
🙂参考(非常感谢) : https://www.jianshu.com/p/c8b53445cbb0