ToDoController.java3(U)
関連タイピング
-
プレイ回数54英語長文187打
-
プレイ回数44英語長文294打
-
プレイ回数56英語長文105打
-
プレイ回数62英語長文815打
-
プレイ回数42英語長文168打
-
プレイ回数44英語113打
-
プレイ回数58英語長文410打
-
プレイ回数56英語長文398打
問題文
(//update)
//update
(@GetMapping("/edit/{id}"))
@GetMapping("/edit/{id}")
(public String edit(@PathVariable("id") Integer id, Model model,)
public String edit(@PathVariable("id") Integer id, Model model,
(RedirectAttributes attributes) {)
RedirectAttributes attributes) {
(ToDo target = toDoService.findByIdToDo(id);)
ToDo target = toDoService.findByIdToDo(id);
(if (target != null) {)
if (target != null) {
(ToDoForm form = ToDoHelper.convertToDoForm(target);)
ToDoForm form = ToDoHelper.convertToDoForm(target);
(model.addAttribute("toDoForm", form);)
model.addAttribute("toDoForm", form);
(return "todo/form";)
return "todo/form";
(} else {)
} else {
(attributes.addFlashAttribute("errorMessage", "taishoude-tagaarimasenn");)
attributes.addFlashAttribute("errorMessage", "taishoude-tagaarimasenn");
(return "redirect:/todos";)
return "redirect:/todos";
(})
}
(})
}
(@PostMapping("/update"))
@PostMapping("/update")
(public String update(@Validated ToDoForm form,)
public String update(@Validated ToDoForm form,
(BindingResult bindingResult,)
BindingResult bindingResult,
(RedirectAttributes attributes) {)
RedirectAttributes attributes) {
(if (bindingResult.hasErrors()) {)
if (bindingResult.hasErrors()) {
(form.setIsNew(false);)
form.setIsNew(false);
(return "todo/form";)
return "todo/form";
(})
}
(ToDo ToDo = ToDoHelper.convertToDo(form);)
ToDo ToDo = ToDoHelper.convertToDo(form);
(toDoService.updateToDo(ToDo);)
toDoService.updateToDo(ToDo);
(attributes.addFlashAttribute("message", "ToDogakousinnsaremasita");)
attributes.addFlashAttribute("message", "ToDogakousinnsaremasita");
(return "redirect:/todos";)
return "redirect:/todos";
(})
}