拒绝访问处理程序不起作用。spring配置在许多xml文件上拆分
- applicationContext-spring-security.xml
<http auto-config='false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint" >
<access-denied-handler error-page='/accessdenied.htm" />
<intercept-url pattern="/login.htm" access="permitAll"/>
<intercept-url pattern='/editprocedure.htm" access="hasAuthority('CAPABILITY_ADD')"/>
</http>
access-denied-handler对于xml配置(如<intercept-url pattern="/addjob.htm" access="hasAuthority('JOB_ADD')"/>
)工作得很好,但是当我使用Preauthorize注解时就不行了!
1.[应用程序]-servlet.xml
...
<security:global-method-security pre-post-annotations="enabled"/>
...
1.主计长
....
@RequestMapping(value="/adminarea.htm")
@PreAuthorize("hasAuthority('ADMIN_AREA')")
protected ModelAndView referenceData() throws Exception
{....}
....
提前感谢你们所有人:)
2条答案
按热度按时间vmpqdwk31#
经过调查,我找到了一个解决我的问题:
1.创建用@ControllerAdvice注解的自定义拒绝访问处理程序类
1.最重要的是为我们的高优先级注解组件定义排序顺序(例如@Order(value = 1))
谢谢
mccptt672#
重新抛出异常,调用AccessDeniedHandler的handle方法。