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
Access Denied Handler. Using an access denied handler instead of a page has the advantage that we can define custom logic to be executed before redirecting to the 403 page. For this, we need to create a class that implements the AccessDeniedHandler interface and overrides the handle() method.
Use this: response. setStatus(403) . Save this answer.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With