Spring MVC(3.0)の同じハンドラーメソッドにマッピングされた2つのURLルートをどのようにできますか?

StackOverflow https://stackoverflow.com/questions/3919706

質問

私はAAを持っています userPanel にマッピングされたメソッド /user/panel URLルート:

@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帰属
所属していません StackOverflow
scroll top