Spring Security2.0 配置 保护方法时遇到了一个问题 请高手指教!!!!

shiyuzhang 2008-10-14 08:31:24
我在给方法配置保护时用了http://family168.com/tutorial/springsecurity/html/ns-config.html#ns-method-security上说的两种方法,

1,在application context中加入<global-method-security secured-annotations="enabled" jsr250-annotations="enabled"/>,然后在需要保护的方法上面加上@Secured("ROLE_ADMIN")


2,在application context配置bean时加上 <protect method="doit*" access="ROLE_ADMIN" />
就类似于<bean:bean id="target" class="com.mycompany.myapp.MyBean">
<intercept-methods>
<protect method="set*" access="ROLE_ADMIN" />
<protect method="get*" access="ROLE_ADMIN,ROLE_USER" />
<protect method="doSomething" access="ROLE_USER" />
</intercept-methods>
</bean:bean>

现在问题是我用哪种方法都会出一个异常:
org.springframework.security.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext

请问这是怎么回事?




...全文
420 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbwhwang 2008-12-17
  • 打赏
  • 举报
回复
acegi摸过一次,现在忘记了。
J2eeFans 2008-12-17
  • 打赏
  • 举报
回复
帮楼主顶。。
boboo_2000_0 2008-10-29
  • 打赏
  • 举报
回复
我觉得是权限名称配置问题,你可以检查一下权限名称是否正确。
shangzq 2008-10-22
  • 打赏
  • 举报
回复
An Authentication object was not found in the SecurityContext

SecurityContext 配置的有问题嘛!
accp206 2008-10-18
  • 打赏
  • 举报
回复
楼主是用的Acegi吧?
这玩艺有点难搞,以前曾经练习过,但是现在忘记得差不多了……
有本书对其介绍得比较详细,且有实例,楼主有兴趣的话可以参考一下:《Spring 2.0核心技术与最佳实践》

帮顶!关注并学习中……
java__king 2008-10-18
  • 打赏
  • 举报
回复
学习.
UP
JJTwo 2008-10-16
  • 打赏
  • 举报
回复
來個高手解決一下
ri881226 2008-10-16
  • 打赏
  • 举报
回复
帮顶
lihan6415151528 2008-10-15
  • 打赏
  • 举报
回复
看了看 ,没有头绪,不过帮朋友顶

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧