1、在登录的时候出现错误时抛出的异常AuthenticationException异常详解
2、 UsernameNotFoundExceptio
AbstractUserDetailsAuthe
try { user = retrieveUser(username, (UsernamePasswordAuthenti<wbr>cationToken) authentication); } catch (UsernameNotFoundExceptio<wbr>n notFound) { logger.debug("User '" + username + "' not found"); if (hideUserNotFoundExceptio<wbr>ns) { throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthe<wbr>nticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } </wbr></wbr></wbr></wbr>
而默认情况下,hideUserNotFoundExceptio
解决办法我们可以直接覆盖org.springframework.security.authentication.dao.AbstractUserDetailsAuthe
当然,这样的解决办法并不好。所以,我们还是走正规的途径,自定义org.springframework.security.authentication.dao.DaoAuthenticationProvide
原来authentication-manager中简单的定义user-service-ref
现在修改如下:
这样修改后,在登录页面获取的异常已经是自己抛出去的UsernameNotFoundExceptio
3、国际化异常信息