1

I found only related topic for c# please don't blame me if I missed the resource.

It looks something like

/project/blablaentered and content with 404.

Effectively I just want to specify my own page when 404 page is thrown.

My security xml:

<security:http auto-config="true" use-expressions="true" >
    <security:form-login login-processing-url="/static/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t"  default-target-url="/home"/>
    <security:intercept-url pattern="/home" access="isAuthenticated()" />
    <security:intercept-url pattern="/home/try" access="hasRole('ROLE_EDITOR')"/>
    <security:access-denied-handler error-page="/accessDenied"/> 
       </security:http>

UPDATE: Please follow for solution: Custom 404 using Spring DispatcherServlet

Community
  • 1
  • 1
Aubergine
  • 5,862
  • 19
  • 66
  • 110

2 Answers2

1

The simplest way is probably enable an error-page element inside web.xml as long as you don't mind it being a plain JSP (ie, no controller). This way, URLs outside your DispatcherServlet which will generate a 404 from your servlet container will follow the same path as any URL that Spring is unable to map to a controller based on your configuration.

If this isn't good enough, you can define a @Exception method for a particular controller, or use a HandlerExceptionResolver.

Dan
  • 10,990
  • 7
  • 51
  • 80
  • Could you please provide sample code? UPDATE: did that, following the link I was unfocused, apparently link provided by me works, sorry. – Aubergine Nov 16 '11 at 06:05
0

You need add class:

import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;


public class SpringSecurityInitializer extends AbstractSecurityWebApplicationInitializer {

    // Do nothing

}
searching9x
  • 1,515
  • 16
  • 16