Initial Commit: Spring-Boot-Project, that pinns down a bug in a test-case
[demos/testing] / src / main / java / de / juplo / TestController.java
1 package de.juplo;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.http.HttpStatus;
6 import org.springframework.stereotype.Controller;
7 import org.springframework.ui.Model;
8 import org.springframework.web.bind.annotation.ExceptionHandler;
9 import org.springframework.web.bind.annotation.RequestMapping;
10 import org.springframework.web.bind.annotation.RequestParam;
11 import org.springframework.web.bind.annotation.ResponseStatus;
12 import org.thymeleaf.exceptions.TemplateInputException;
13
14 @Controller
15 public class TestController
16 {
17     private final static Logger LOG =
18             LoggerFactory.getLogger(TestController.class);
19
20
21     @RequestMapping("/controller.html")
22     public String controller(
23             @RequestParam String template,
24             Model model
25     )
26     {
27         model.addAttribute("template", template);
28         return template;
29     }
30
31     @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
32     @ExceptionHandler(TemplateInputException.class)
33     public void templateInputException(TemplateInputException e)
34     {
35         LOG.error("{}: {}", HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
36     }
37 }
38