spring-boot 配置thymeleaf模板引用shiro标签

2023-09-12 12:50:42

spring-boot 配置thymeleaf模板引用shiro标签

application.yml

spring:
    thymeleaf:
        cache: false
        suffix: .html
        encoding: UTF-8
        prefix: classpath:/views/
        content-type: text/html
        mode: LEGACYHTML5

main.html

<li shiro:hasRole ="admin">
<shiro:principal property="userName"/>

pom.xml

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
    <groupId>com.github.theborakompanioni</groupId>
    <artifactId>thymeleaf-extras-shiro</artifactId>
    <version>1.2.1</version>
</dependency>
<dependency>
	<groupId>org.apache.shiro</groupId>
	<artifactId>shiro-core</artifactId>
	<version>1.2.4</version>
</dependency>
<dependency>
    <groupId>net.sourceforge.nekohtml</groupId>
    <artifactId>nekohtml</artifactId>
    <version>1.9.22</version>
</dependency>

ShiroConfig.java

    @Bean
    public SecurityManager securityManager() {
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        // 设置realm.
        securityManager.setRealm(customRealm);
        return securityManager;
    }
  • 作者:kisstear0
  • 原文链接:https://blog.csdn.net/kisstear0/article/details/84873843
    更新时间:2023-09-12 12:50:42