2010-10-12 71 views
2

我有AA userPanel方法映射到/user/panel URL路径:如何将两个URL路由映射到Spring MVC(3.0)中的相同处理程序方法?

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

回答

8

@RequestMapping可以采取多个路径:

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