繁体   English   中英

如何在Spring MVC(3.0)中将两个URL路由映射到相同的处理程序方法?

[英]How can you have two URL routes mapped to the same handler method in Spring MVC (3.0)?

我有一个userPanel方法映射到/user/panel URL route:

@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方法处理这两个路由以避免重复?

@RequestMapping可以采用多个路径:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM