KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a spring 3 application with the configurations given below. When any user tries to access a page and he/she isn't logged in, I get an Access is Denied exception with an ugly stack trace. How do I handle this exception and not let it dump out a stack trace. I implemented my own access-denied-handler but that doesn't get invoked. Based on the type of the requested resource, I would like to show custom error messages or pages. Here is my spring configuration. How do I get Spring to invoke my access-denied-handler . Here is my spring configuration <security:http auto-config='true'> <security:intercept-url pattern="/static/**" filters="none"/> <security:intercept-url pattern="/login" filters="none"/> <security:intercept-url pattern="/**" access="ROLE_USER" /> <security:form-login login-page="/index" default-target-url="/home" always-use-default-target="true" authentication-success-handler-ref="AuthenticationSuccessHandler" login-processing-url="/j_spring_security_check" authentication-failure-url="/index?error=true"/> <security:remember-me key="myLongSecretCookieKey" token-validity-seconds="1296000" data-source-ref="jdbcDataSource" user-service-ref="AppUserDetailsService" /> <security:access-denied-handler ref="myAccessDeniedHandler" /> </security:http> <bean id="myAccessDeniedHandler" class="web.exceptions.handlers.AccessDeniedExceptionHandler"> <property name="errorPage" value="/public/403.htm" /> </bean> The custom class for handling this exception is given below public class AccessDeniedExceptionHandler implements AccessDeniedHandler { private String errorPage; @Override public void handle(HttpServletRequest request, HttpServletResponse response,
Tags (comma-separated)
Save Edits
Cancel