简体   繁体   中英

how to redirect the access denied page in spring security?

I want to know how to redirect the access denied page in spring security? Shall I use some kind of handler or edit in web.xml?

thanks

Have you read the relevant sections of the Spring Security manual, namely the AccessDeniedHandler and the namespace appendix .

If you want more control, you can use

 <http use-expressions="true">
     <intercept-url pattern="/denied/*" access="permitAll" />

     <access-denied-handler error-page="/denied">

     <!-- The rest of your configuration -->
 </http>

Where /denied maps to a web controller class which you write. Make sure /denied/** is unprotected.

If this doesn't answer your question, could you please explain in some more detail what you're trying to achieve?

Use a RedirectView for this purpose

Sample

       return new ModelAndView(new RedirectView(request.getContextPath()+ "urlPath"), modelMap);

or use the redirect: prefix.

您是否希望在页面发生跳转时重定向页面,或者您是否因为安全原因而重定向页面。只有在该页面发生异常时才需要处理程序。通过使用处理程序,我们可以重定向到我们需要的目标页面。或者,如果您想每次都重定向到该特定页面以获得安全性,我们可以使用web.xml。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM