【发布时间】:2013-05-29 03:16:55
【问题描述】:
我在我的 struts2 应用程序上应用 spring security 我可以使用拦截器 url 来提供对主 url 的访问,但不能访问它们的子集。
例如,我需要授予具有客户角色的用户仅查看书籍的权限,因此我使用 以下
<http auto-config="true" access-denied-page="/not.jsp" use-expressions="true">
....
<intercept-url pattern="/Books/view*" access="hasRole('ROLE_CUSTOMER')"/>
所以我想用户应该能够访问 localhost:8888/Books/view.action 但他们没有,它会将他们重定向到 not.jsp 页面(访问拒绝页面)
我已经尝试了以下所有方法,但都没有成功
<intercept-url pattern="/Books/view.action" access="hasRole('ROLE_CUSTOMER')"/>
<intercept-url pattern="/Books/view**" access="hasRole('ROLE_CUSTOMER')"/>
<intercept-url pattern="/Books/view.action*" access="hasRole('ROLE_CUSTOMER')"/>
唯一有效的是以下一个,它可以访问我不想要的所有操作(编辑、删除和查看)。
<intercept-url pattern="/Books/*" access="hasRole('ROLE_CUSTOMER')" />
【问题讨论】:
标签: java jakarta-ee struts2 spring-security