-
-
- static class CustomErrorController extends BasicErrorController
- {
- public final static String TEMPLATE_INPUT_EXCEPTION =
- TemplateInputException.class.getCanonicalName();
-
-
- CustomErrorController(
- ErrorAttributes errorAttributes,
- ErrorProperties errorProperties
- )
- {
- super(errorAttributes, errorProperties);
- }
-
-
- @Override
- public ModelAndView errorHtml(
- HttpServletRequest request,
- HttpServletResponse response
- )
- {
- Map<String, Object> model =
- getErrorAttributes(
- request,
- isIncludeStackTrace(request, MediaType.TEXT_HTML)
- );
-
- String view;
-
- switch ((String)model.get("exception"))
- {
- case "org.thymeleaf.exceptions.TemplateInputException":
- response.setStatus(HttpStatus.SC_NOT_FOUND);
- view = "templates/404";
- break;
-
- default:
- response.setStatus(getStatus(request).value());
- view = "templates/500";
- break;
- }
-
- return new ModelAndView(view, model);
- }
- }