Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSpring MVC: Guidance on reporting un-handled errors as data when implementing a REST API [SPR-9290] #13928
Comments
This comment has been minimized.
This comment has been minimized.
Rossen Stoyanchev commented I've updated the reference docs with information on customizing the default Servlet container error page and added a sample project. Also note that you need Tomcat 7.0.29 or higher to be able to define an <error-page> element in web.xml that contains only a location sub-element, i.e. is not mapped to any specific status code or exception type. |
This comment has been minimized.
This comment has been minimized.
Pavel Orehov commented I'm trying to use that new feature but things does not work as expected. |
This comment has been minimized.
This comment has been minimized.
Michael Osipov commented A very reasonable issue which am fighting with too. |
spring-issuemaster commentedMar 30, 2012
•
edited
Keith Donald opened SPR-9290 and commented
HttpServletResponse#sendError's default behavior for reporting unrecoverable errors such as 404, 405, 406, and 500 sends HTML back to the client, which is not appropriate for REST APIs where responses should be in the form of data (usually JSON, alternatively XML). Spring MVC currently doesn't provide any guidance on how to deal with this issue e.g. should the developer customize the sendError behavior by defining custom error page JSPs that return JSON? Do they instead configure something in Spring MVC itself? It'd be helpful to provide application developer guidance here.
This was a useful resource:
http://blog.newsplore.com/2010/08/04/restful-error-handling-with-tomcat-springmvc
Affects: 3.1.1
Issue Links: