How can you have two URL routes mapped to the same handler method in Spring MVC (3.0)?
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 开发者_Python百科userPanel
method handle both routes to avoid duplication?
@RequestMapping
can take multiple paths:
@RequestMapping(value = {"/user/panel", "/panel"}, method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)
精彩评论