This is my controller which gets the id from the url :
@RequestMapping(value = "/user/users", method = RequestMethod.GET, params = {"getId"})
@ResponseBody
public ModelAndView getClientStat(@RequestParam(value="getId", required = true) String getId) {
ModelAndView modelAndView = new ModelAndView();
long userId=0;
userId=Long.parseLong(getId);
Client c=userService.getUserById(userId);
modelAndView.addObject("userName", c.getName() );
modelAndView.setViewName("user/users");
return modelAndView;
}
This returns a null pointer exception but the thing is when I just put getID in the modelAndView, like this :
modelAndView.addObject("id",getId)
It does add the responding id. How can I fix this ? I think the problem is when parsing the string,cuz when that part is removed, it works well.