利用spring security2权限控制遇到的一个郁闷问题

用户登录后,就可以获取用户的信息。

在Actin这样获取到


[code="java"]UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
今天突然不可以了,检查了好多遍都找不到原因,一直报上面那行是空指针异常,然后把上面信息打印出来


SecurityContextHolder.getContext(): org.springframework.security.context.SecurityContextImpl@ffffffff: Null authentication,



SecurityContextHolder.getContext().getAuthentication():null
问题就出在这里,在网上搜索了资料,解决了:就是在web.xml文件中的spring security部分的配置文件放到struts和spring,Hibernate等配置文件前面就好了。

参考这里:http://www.iteye.com/topic/319965?page=3

 

你可能感兴趣的:(spring,Hibernate,struts,Security,ITeye)