在 Spring MVC (3.0) 中,如何将两个 URL 路由映射到同一个处理程序方法?
我有一个 userPanel
方法映射到 /user/panel
URL 路由:
@RequestMapping(value = "/user/panel", method = RequestMethod.GET)
public final String userPanel(HttpServletRequest request, ModelMap model)
但是,我还希望 userPanel
方法来处理路由< code>/panel 而不创建如下所示的单独方法:
@RequestMapping(value = "/panel", method = RequestMethod.GET)
public final String panel(HttpServletRequest request, ModelMap model)
是否有办法让 userPanel
方法处理这两个路由以避免重复?
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 userPanel
method handle both routes to avoid duplication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@RequestMapping
可以采用多个路径:@RequestMapping
can take multiple paths: