[英]How to handle 404 error in spring MVC using Controller Advice
i want to redirect all 404 errors to a error page, i have created a controllerAdvice but my method does not catch 404 error, i am using spring 3.3 throwExceptionIfNoHandlerFound to true does not work 我想将所有404错误重定向到错误页面,我创建了controllerAdvice,但是我的方法没有捕获404错误,我正在使用Spring 3.3 throwExceptionIfNoHandlerFound为true无法正常工作
@ExceptionHandler(NoSuchRequestHandlingMethodException.class)
public ModelAndView handleNoSuchRequestHandlingMethod(final NoSuchRequestHandlingMethodException ex)
{
final ModelAndView mav = new ModelAndView(ERRORJSP);
return mav;
}
web.xml中的常绿<error-page>
可以完成此任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.