spring-boot与thymeleaf模板整合shiro标签内容

添加依赖项

1
2
3
4
5
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>2.0.0</version>
</dependency>

添加Bean对象

1
2
3
4
5
6
7
8
9
/**
* shiro 标签的Bean。
*
* @return
*/
@Bean
public ShiroDialect shiroDialect() {
return new ShiroDialect();
}

页面添加对标签的引用,添加方式如下:

1
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

上述配置成功后即可使用shiro相关的标签

  1. 直接对代码块进行控制

    1
    2
    3
    4
    5
    <shiro:hasPermission name="P0101">
    <li>
    <a data-href="/ticket/spot/view/list" data-title="景点" href="javascript:void(0)">景点</a>
    </li>
    </shiro:hasPermission>
  2. 通过html属性方式进行控制

    1
    <a data-href="/ticket/spot/view/list" data-title="景点" href="javascript:void(0)" shiro:hasPermission name="P0101">景点</a>
文章目录
  1. 1. 添加依赖项
  2. 2. 添加Bean对象
  3. 3. 页面添加对标签的引用,添加方式如下:
  4. 4. 上述配置成功后即可使用shiro相关的标签
|
载入天数...载入时分秒...