springboot如何在ftl页面上使用shiro标签
这篇文章将为大家详细讲解有关springboot如何在ftl页面上使用shiro标签,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
1.首先第一步导入依赖
<dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>1.2.1</version> </dependency>
2.在配置shiro权限的方法内加入
@Bean public ShiroDialect shiroDialect() { return new ShiroDialect(); }
3.ftl页面中引入命名空间
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4.ftl页面中使用标签
<@shiro.hasRole name="merchants"> <div> 我有这个角色哦! </div> </@shiro.hasRole>
关于“springboot如何在ftl页面上使用shiro标签”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。