自打用了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一片你抄我抄...

390

被折叠的 条评论
为什么被折叠?



