spring data jpa update
Posted lshan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring data jpa update相关的知识,希望对你有一定的参考价值。
一:在controller 加上:
@Controller @RequestMapping("/user") public class UserController { @Autowired private UserService userService; private static final Logger LOG = LoggerFactory.getLogger(UserController.class); /*************use to update part is null problem*********************/ @ModelAttribute public void getUser(@RequestParam(value = "id", required = false) Integer id, Model model) { if (id != null) { User user = userService.getById(id); model.addAttribute("user", user); } } /************** tologin ****************/ @RequestMapping(value="/tologin",method = RequestMethod.GET) public String toLogin(){ return "redirect:/index.html"; }
二:
update 的时候使用 save 即可:
以上是关于spring data jpa update的主要内容,如果未能解决你的问题,请参考以下文章