Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9290

Spring MVC: Guidance on reporting un-handled errors as data when implementing a REST API

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 3.1.1
    • Fix Version/s: None
    • Component/s: Web
    • Last commented by a User:
      true

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                kdonald Keith Donald
                Last updater:
                Michael Osipov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 37 weeks ago