Tag Archives: error handling in spring

Customizing the Default Servlet Container Error Page


web.xml /error Controller @RequestMapping(value=”/error”, produces=”application/json”) @ResponseBody public Map handle(HttpServletRequest request) { Map map = new HashMap(); map.put(“status”, request.getAttribute(“javax.servlet.error.status_code”)); map.put(“reason”, request.getAttribute(“javax.servlet.error.message”)); return map; } OR in a JSP <%@ page contentType=”application/json” pageEncoding=”UTF-8″%> { status:<%=request.getAttribute(“javax.servlet.error.status_code”) %>, reason:<%=request.getAttribute(“javax.servlet.error.message”) %> }

https://pickthecode.wordpress.com/2015/07/02/customizing-the-default-servlet-container-error-page/