一:DefaultHandlerExceptionResolver
- 对一些特殊的异常进行处理,比 如NoSuchRequestHandlingMethodException、HttpReques tMethodNotSupportedException、HttpMediaTypeNotSuppo rtedException、HttpMediaTypeNotAcceptableException 等。
二:实现
1.创建方法
//前端请求是get请求,定义的方法是post请求,会引起HttpReques tMethodNotSupportedException异常
@RequestMapping(value="testDefaultHandlerExceptionResolver",method=RequestMethod.POST)
public String testDefaultHandlerExceptionResolver() {
System.out.println("testDefaultHandlerExceptionResolver");
return "success";
}
2.测试页面
<a href="testDefaultHandlerExceptionResolver">test DefaultHandlerExceptionResolver</a>
<br>