views:

23

answers:

1

I have a a userPanel method mapped to the /user/panel URL route:

@RequestMapping(value = "/user/panel", method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)

However, I would also like the userPanel method to handle the route /panel without creating a separate method such as this:

@RequestMapping(value = "/panel", method = RequestMethod.GET)
public final String panel(HttpServletRequest request, ModelMap model)

Is there a way to have the userPanel method handle both routes to avoid duplication?

+4  A: 

@RequestMapping can take multiple paths:

@RequestMapping(value = {"/user/panel", "/panel"}, method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)
skaffman