[英]How do you switch between two request mappings handled by the same Spring MVC mapping handler?
[英]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.