当前位置:主页 > 软件编程 > JAVA代码 >

springboot 在ftl页面上使用shiro标签的实例代码

时间:2021-04-11 08:52:51 | 栏目:JAVA代码 | 点击:

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>  

总结

您可能感兴趣的文章:

相关文章