私はハンドラメソッドSpring MVCのRestControllerあいまいPathVariableマッピング
@RestController
public class TestController {
...
@GetMapping(name = "/test")
public Test testMethod() {
return testService.getTest();
}
@GetMapping(name = "/test/{count}")
public List<Test> getTestList2(@PathVariable(name = "count") Integer count) {
return testService.getTestList(count);
}
}
GET 2 を持っていると私はエラーを取得:私は1つの方法をコメントする場合
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'testController' method
public java.util.List<models.Test> TestController.getTestList2(java.lang.Integer)
to {[],methods=[GET]}: There is already 'testController' bean method
はすべてが動作罰金
HTTP指定し、常に望ましいすべて:// localhostを:8080 /テストを? count = 3 not worked – ip696
@ ip696あなたは正しいURLにヒットしていません。 \t ** localhost:8080/test/3 **です。どんな方法でも、私は答えを書き換えて自分自身をテストしました。もう一度それを読んでみてください。あなたの問題を解決するはずです。 –
@ ip696これは何の反応もないことは不条理です。あなたは助けを求め、コミュニティも望んでいます。あなたがそれを見つけることができればそれはrecickkし、accpetedにしてください。 –