zoukankan      html  css  js  c++  java
  • 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 即可:

  • 相关阅读:
    Constructor构造方法
    overload重载
    static关键字
    this关键字
    继承
    ORACLE数据库 常用命令和Sql常用语句
    常见单词
    L贪心基础
    J贪心
    K贪心
  • 原文地址:https://www.cnblogs.com/lshan/p/9981496.html
Copyright © 2011-2022 走看看