0
我正在使用Tiles 3.0和Spring Validator。 如何編輯ulr這樣的用戶,比如.../edit/{userID},並且有一些驗證錯誤,然後用相同的url返回到該視圖。我的問題是錯誤沒有顯示。 我該怎麼做? 對不起,我的英語不好!彈出式窗口+ validtion有錯誤時驗證
這裏是我的代碼:
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
public String getEditUser(@PathVariable int id, Model model) {
User user = userService.getUserById(id);
model.addAttribute("user", user);
return "user_edit";
}
@RequestMapping(value = "/edit/{id}", method = RequestMethod.POST)
public String editUser(@PathVariable int id,
@Validated(GroupEdit.class) @ModelAttribute User user,
BindingResult result, Model model) {
if (result.hasErrors()){
return "redirect:edit/" + user.getUserId(); //how can i return here?
}
userService.updateUser(user);
return "redirect:edit/" + user.getUserId();
}