How do I redirect Exception to an error page?

0

How do I redirect UsernameNotFoundException to a page?

if ( user == null ) {
   log.info( "Email " + email + " não é um ususário cadastrado." );
   throw new UsernameNotFoundException( "Email " + email + " não é um ususário cadastrado." );
}

I think I was not very clear on my question, Spring returns an error page, with the following message:

  

Whitelabel Error Page

     

This application has no explicit mapping for / error, so you are seeing   this as a fallback.

     

Mon Jul 31 15:20:43 BRT 2017 There was an unexpected error   (type = Forbidden, status = 403). Access Denied

I would like the error message to be defined through an HTML page I created.

I'm using AngularJS with Spring, how do I map it?

    
asked by anonymous 31.07.2017 / 19:32

1 answer

0

Add authentication-failure-url property to your spring-security configuration xml

Example:

<form-login login-page="/"
        login-processing-url="/login"
        username-parameter="username"
        password-parameter="password" 
        default-target-url="/userhome" 
        always-use-default-target="true"
        authentication-failure-url="/error" 
         />
    
31.07.2017 / 19:59