ToDoController.java3(U)

関連タイピング
-
src/main/resources
プレイ回数67英語長文294打 -
src/main/resources
プレイ回数83英語長文105打 -
src/main/resources
プレイ回数103英語長文815打 -
src/main/resources
プレイ回数92英語長文717打 -
src/main/java
プレイ回数69英語113打 -
src/main/java
プレイ回数85英語長文628打 -
src/main/java
プレイ回数65英語長文168打 -
src/main/java
プレイ回数82英語長文240打
問題文
(//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";
(})
}