SpringMVC---异常处理DefaultHandlerExceptionResolver

一: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>
发布了64 篇原创文章 · 获赞 12 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_39093474/article/details/103901776