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: