【发布时间】:2017-03-30 14:14:33
【问题描述】:
这是我的更新用户方法:
@ResponseBody
@Transactional
@RequestMapping(value = "/profile/edit/{id}", method = RequestMethod.POST)
public String updateUser(@PathVariable("id") final Integer id, String firstname, String lastname, final RedirectAttributes redirectAttributes) {
respository.updateFirstname(id,firstname);
respository.updateLastname(id, lastname);
redirectAttributes.addFlashAttribute("message", "Successfully changed..");
return "redirect:/profile";
}
一切正常。还有数据库中的更新。但重定向只是一个字符串,不要更改路径。谁能告诉我为什么?
【问题讨论】:
-
删除
@ResponseBody。让你的控制器事务性也是一个糟糕的主意......你应该有一个事务性边界的服务(这样你就可以重用这些东西)。
标签: spring spring-mvc spring-security spring-boot thymeleaf