加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

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

发布时间:2020-12-14 19:48:15 所属栏目:Java 来源:网络整理
导读:1.首先第一步导入依赖 dependency groupIdcom.github.theborakompanioni/groupId artifactIdthymeleaf-extras-shiro/artifactId version1.2.1/version /dependency 2.在配置shiro权限的方法内加入 @Bean public ShiroDialect shiroDialect() { return new Sh

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标签的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程小技巧网站的支持!

您可能感兴趣的文章:

  • spring boot实战教程之shiro session过期时间详解
  • spring boot 1.5.4 集成shiro+cas,实现单点登录和权限控制
  • Spring shiro + bootstrap + jquery.validate 实现登录、注册功能
  • SpringBoot+Shiro学习之密码加密和登录失败次数限制示例

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读