Added checkboxes, that are stored in a map
[demos/spring-boot] / src / main / java / de / juplo / demo / DemoController.java
1 package de.juplo.demo;
2
3
4 import java.util.stream.Collectors;
5 import lombok.extern.slf4j.Slf4j;
6 import org.springframework.stereotype.Controller;
7 import org.springframework.web.bind.annotation.ModelAttribute;
8 import org.springframework.web.bind.annotation.RequestMapping;
9
10
11 /**
12  * Controller to demonstrate the behavior of checkboxes
13  * @author Kai Moritz
14  */
15 @Controller
16 @Slf4j
17 public class DemoController
18 {
19   @RequestMapping("/")
20   public String display(@ModelAttribute Form form)
21   {
22     log.info(
23         "option={}, inner={}{}",
24         form.option,
25         form.inner.option,
26         form.map
27             .entrySet()
28             .stream()
29             .map(entry -> entry.getKey() + "=" + entry.getValue())
30             .collect(Collectors.joining(", ", ", ", "")));
31     return "form";
32   }
33 }