WIP: welcom + error - 404 anstatt 500
[maven-thymeleaf-skin] / src / main / java / de / juplo / thymeproxy / DefaultExceptionHandler.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 DefaultExceptionHandler
20 {
21   public DefaultExceptionHandler()
22   {
23   }
24
25
26   @ResponseStatus(HttpStatus.NOT_FOUND)
27   @ExceptionHandler(value = TemplateInputException.class)
28   public ModelAndView templateInputExceptionHandler(
29       HttpServletRequest request,
30       TemplateInputException e
31       )
32   {
33     ModelAndView mav = new ModelAndView("templates/404");
34     mav.addObject("template", e.getTemplateName());
35     mav.addObject("uri", request.getRequestURI());
36     return mav;
37   }
38 }