@RequestMapping(value = "/userId={id}", method = RequestMethod.GET) public ModelAndView showUser(@PathVariable("id") Long id) { ModelAndView model = new ModelAndView("profile"); User user = null; if (id != null) { // Do null check for id user = userRepository.findOne(id); // Do null check for user } if (user != null) { model.addObject("user", user); } model.addObject("signupForm", new SignupForm()); return model; }
@RequestMapping(value = "/profile", method = RequestMethod.GET) public ModelAndView profile(@RequestParam(value = "userId", required = true) long userId) { ModelAndView model = new ModelAndView("profile"); model.addObject("User", userDao.findOne(userId)); return model; }