Reputation: 233
I want to allow a logged in user to access a page and automatically retrieve the modules assigned to them. So to that end I used the @PathVariable with the id as value.
My controller
@RequestMapping(value="/main/user/setter/settingpage/{id}", method =
RequestMethod.GET)
public String showStaffModules(@PathVariable("id") Integer id, ModelMap map,
HttpServletRequest request) {
map.addAttribute("cp", request.getContextPath());
map.addAttribute("Setter", userService.getWithModules(id));
return "/main/user/setter/settingpage";
So far though an error keeps coming up:
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP
request with URI [/app/main/user/setter/settingpage] in DispatcherServlet with
name 'appServlet'
The page that is being requested is in the right location but it's not being returned. Would anyone know why? Thanks.
Upvotes: 1
Views: 1108
Reputation: 17371
You are missing the path variable in url /app/main/user/setter/settingpage
so it's not valid. You should create another RequestMapping
to match the url without the variable.
@RequestMapping(value="/main/user/setter/settingpage", method=RequestMethod.GET)
P.s. I assume you have a mapping on the controller that maps to /app
Upvotes: 1