次のような1つのリクエストマッピングを定義する親クラスPがあります。
public abstract class P {
@RequestMapping(value = "/a/b/c", method = RequestMethod.POST)
public String productLink(@RequestParam("abc") String json) throws Exception {
return getProductLinks(json);
}
}
私には子供向けのController
クラスがいくつかありClassImpl
、そのうちの1つです。
@Controller
public class ClassImpl extends P {
@RequestMapping(value = "/start", method = RequestMethod.GET)
public String start(@RequestParam(value = "keyword", required = true) String keyword,
@RequestParam(value = "keywordId", required = true) long keywordId) throws Exception {
//Something
}
}
このアプリを1つの子クラスのみで実行すると、正常に動作しますが、複数の子コントローラーで問題が発生します。
アプリケーションを実行すると、次のようなエラーが発生します"Cannot map handler ClassImpl to URL path [/a/b/c]: There is already handler [a.b.c.d.ClassImpl@a92aaa] mapped"
It seems that because of multiple child classes, it is unable to find the controller for this mapping which is understood.
@RequestMapping
各クラス(または1つの別々のクラス)で定義することが唯一の方法ですか?私はすべての場所に同様のコードを置きたくありません。親クラスに保持して使用し続けるための回避策はありますか?
ありがとう、