WIP: welcom + error - 404 anstatt 500
[maven-thymeleaf-skin] / src / main / java / de / juplo / thymeproxy / ExceptionMappings.java
1 package de.juplo.thymeproxy;
2
3
4 import javax.servlet.http.HttpServletRequest;
5 import org.springframework.http.HttpStatus;
6 import org.springframework.web.bind.annotation.ControllerAdvice;
7 import org.springframework.web.bind.annotation.ExceptionHandler;
8 import org.springframework.web.bind.annotation.ResponseStatus;
9 import org.springframework.web.servlet.ModelAndView;
10 import org.thymeleaf.exceptions.TemplateInputException;
11
12
13
14 /**
15  *
16  * @author Kai Moritz
17  */
18 @ControllerAdvice
19 public class ExceptionMappings
20 {
21   @ResponseStatus(HttpStatus.NOT_FOUND) 
22   @ExceptionHandler(value = TemplateInputException.class)
23   public ModelAndView templateInputExceptionHandler(
24       HttpServletRequest request,
25       TemplateInputException e
26       )
27   {
28     ModelAndView mav = new ModelAndView("templates/404");
29     mav.addObject("template", e.getTemplateName());
30     mav.addObject("uri", request.getRequestURI());
31     return mav;
32   }
33 }