我有userPanel
方法映射到/user/panel
网址:
@RequestMapping(value = "/user/panel", method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)
但是,我还希望userPanel
方法处理路由/panel
而不创建单独的方法,如下所示:
@RequestMapping(value = "/panel", method = RequestMethod.GET)
public final String panel(HttpServletRequest request, ModelMap model)
有没有办法让userPanel
方法处理这两条路由以避免重复?
答案 0 :(得分:9)
@RequestMapping
可以采用多种途径:
@RequestMapping(value = {"/user/panel", "/panel"}, method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)