import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.thymeleaf.util.StringUtils;
/**
.collect(Collectors.joining(", ", ", ", "")));
return "form";
}
+
+ @RequestMapping(path = "/", params = "add")
+ public String add(@ModelAttribute Form form, @RequestParam String name)
+ {
+ if (!StringUtils.isEmptyOrWhitespace(name))
+ {
+ form.map.put(name.trim(), Boolean.FALSE);
+ log.info("Added option \"{}\" to the map", name.trim());
+ }
+ else
+ {
+ log.info("Ignoring empty option-name");
+ }
+ return display(form);
+ }
}