49

如何使用Spring优雅地处理REST异常-爱编程厨师的博客

 5 years ago
source link: http://blog.51cto.com/13902811/2170945
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
本文将举例说明如何使用Spring来实现REST API的异常处理。我们将同时考虑Spring 3.2和4.x推荐的解决方案,同时也会考虑以前的解决方案。在Spring 3.2之前,Spring MVC应用程序中处理异常的两种主要方式是:HandlerExceptionResolver或注解@ExceptionHandler。这两种方式都有明显的缺点。在3.2之后,我们有了新的注解@ControllerAdvice来解决前两个解决方案的局限性。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK