shiro权限框架,前端验证是为jsp设计的,其中的tag只能用于jsp系列的模板引擎。最近项目使用了thymeleaf作为前端模板引擎,使用HTML文件,没法引入shiro的tag lib,此时如果要使用shiro的话,可以引入 thymeleaf-extras-shiro.jar这个拓展包来曲线实现shiro的前端验证。
在pom.xml中加入如下依赖:
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>1.0.2</version>
</dependency>
关于版本,可以在maven仓库中查询:http://mvnrepository.com/artifact/com.github.theborakompanioni/thymeleaf-extras-shiro/1.0.2
thymeleaf-extras-shiro.jar在git hub的地址:https://github.com/theborakompanioni/thymeleaf-extras-shiro,上面有具体的使用说明。
引入jar包后,我们要

本文介绍了如何在使用Thymeleaf作为前端模板引擎的项目中,结合Shiro权限框架进行前端验证。由于Thymeleaf不支持Shiro的tag库,文章提到了引入thymeleaf-extras-shiro.jar拓展包作为解决方案,并提供了相关依赖配置。此外,还讨论了如何在Java配置中设置Thymeleaf引擎,并提到可以通过自定义标签扩展Shiro的hasAnyPermission功能。
最低0.47元/天 解锁文章
338

被折叠的 条评论
为什么被折叠?



