springboot2 + thymeleaf + shiro1.4+redis里前端shiro标签没法用

自打用了shiro,项目是三天两头出BUG...同样的配置摆在我这就不成。。。心痛

如今遇到了个更奇怪的问题,是前后端耦合的项目,直接调Index.html里的登陆接口可以实现登陆,但加上shiro标签以后页面都进不去,好嘛,提示securityManager没得,我真是!

用的是这个JAR

        <dependency>
			<groupId>com.github.theborakompanioni</groupId>
			<artifactId>thymeleaf-extras-shiro</artifactId>
			<version>2.0.0</version>
		</dependency>

 这是shiroConfig里的相关配置

 /**
     *
     * @param
     * @return at.pollux.thymeleaf.shiro.dialect.ShiroDialect
     * @author Zain
     * @description thymeleaf页面使用shiro标签控制按钮是否显示
     * @date 2019/1/7 23:43
     */
    @Bean("shiroDialect")
    public ShiroDialect shiroDialect(){
        ShiroDialect dialect = new ShiroDialect();
        return dialect;
    }

    /**
     * 
     * @param
     * @return org.springframework.beans.factory.config.MethodInvokingFactoryBean
     * @author Zain
     * @description Spring静态注入:让某个方法的返回值注入bean实例
     * @date 2019/1/9 17:18
     */
    @Bean
    public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager){
        MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
        bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
        bean.setArguments(securityManager);
        return bean;
    }

 然后呢网上找了很多解决办法,下面这个方法失败咯!

@Bean
    public FilterRegistrationBean delegatingFilterProxy(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        DelegatingFilterProxy proxy = new DelegatingFilterProxy();
        proxy.setTargetFilterLifecycle(true);
        proxy.setTargetBeanName("shiroFilter");
        filterRegistrationBean.setFilter(proxy);
        return filterRegistrationBean;
    }

为了避免一切可能放上前端的代码:

<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

    <shiro:guest>
           <a href="#" data-toggle="modal" data-target="#myModal">登录</a>
    </shiro:guest>

大过年的 心里拔凉拔凉的,CSDN一片你抄我抄... 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值