Reputation: 5667
Springs MVC. I am trying to catch 404 page errors but code is not getting coded. Am I missing something?
@ControllerAdvice
public class GeneralHandler
{
private static final Logger LOGGER = getLogger(GeneralHandler.class);
@ExceptionHandler
public ModelAndView handleException (NoSuchRequestHandlingMethodException ex) {
LOGGER.warn(ex.toString());
return new ModelAndView("404");
}
}
Upvotes: 1
Views: 807
Reputation: 3774
It seems that it can't be done using @ExceptionHandler
: https://stackoverflow.com/a/3230559/322166
Instead of that, you'll need to configure that behaviour in your web.xml
:
<error-page>
<error-code>404</error-code>
<location>/your-error-page.html</location>
</error-page>
Upvotes: 2