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
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.
Do you want to redirect the page when a excpetion happens to the page or do you want to redirect the page for secuirty reasons.A handler is required only if there is an exception been occuring to that page.By using a handler we can redirect to our required destination page.Or if you want to redirect to that particular page every time for security we can go for web.xml.