I have a controller that has the following request mapping
@RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
public ModelAndView loadUserPage(@PathVariable("id") String id) {
ModelAndView modelAndView = new ModelAndView("editUser.jsp","editUser", new User());
modelAndView.addObject("activeUser",getActiveUserByID(id));
return modelAndView;
}
and in my home.jsp, I have a href link as below
<a href="${pageContext.request.contextPath}/user/${eachUser.userId}">Click Here</a>
But when I click on the above link, the URL directs to localhost:8080/user/1234 (assuming that the user id is 1234) but it throws 404 error saying that the /user/editUser.jsp is not found. I was wondering why the "/user" is appended on to the jsp path?
And I don't hit this issue if I use @RequestParam and change the href URL to "/user?id=${eachUser.userId}".