一:在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 即可:

posted on 2018-11-19 09:43  lshan  阅读(551)  评论(0编辑  收藏  举报