@RequestMapping(value = "save") public String save(Task task, RedirectAttributes redirectAttributes) { taskManager.saveTask(task); redirectAttributes.addFlashAttribute("message", "创建任务" + task.getTitle() + "成功"); return "redirect:/task/"; }
@RequestMapping(value = "delete/{id}") public String delete(@PathVariable("id") Long id, RedirectAttributes redirectAttributes) { taskManager.deleteTask(id); redirectAttributes.addFlashAttribute("message", "删除任务成功"); return "redirect:/task/"; }
@RequestMapping(value = {"list", ""}) public String list(Model model) { List<Task> tasks = taskManager.getAllTask(); model.addAttribute("tasks", tasks); return "taskList"; }