@RequestMapping(value = "create", method = RequestMethod.POST) public String create(@Valid Task newTask, RedirectAttributes redirectAttributes) { User user = new User(getCurrentUserId()); newTask.setUser(user); taskService.saveTask(newTask); redirectAttributes.addFlashAttribute("message", "创建任务成功"); return "redirect:/task/"; }
@RequestMapping(value = "save") public String save(Task task, RedirectAttributes redirectAttributes) { taskManager.saveTask(task); redirectAttributes.addFlashAttribute("message", "创建任务" + task.getTitle() + "成功"); return "redirect:/task/"; }