Programming/Spring
ambiguous handler methods mapped for...
Cafe_Caramelo
2022. 2. 12. 03:23
반응형
ambiguous handler methods mapped for...
말 그대로 요청 URI가 애매하기 때문이다. 애매한 이유는 중복되는 URI가 있기 때문일 것이다.
본인은 아래 코드를 통해 이 에러와 마주했다.
@GetMapping("/exists/{userId})
public ResponseEntity<Void> checkUserId ...
@GetMapping("/exists/{userEmail}
public ResponseEntity<Void> checkUserEmail...
본인은 처음에 두 메소드의 URI가 서로 다르다고 생각했다. /exists/는 동일하지만 쿼리 스트링으로 들어가는 값이 다르기 때문에 다른 URI 아닌가? 하고 생각했다. 아니다. 두 메소드의 URI는 동일하다. /exists/ 까지가 URI로 인식되기 때문이다.
그래서 코드를 아래와 같이 수정했고, 결과는 성공.
@GetMapping("/id/{userId})
public ResponseEntity<Void> checkUserId ...
@GetMapping("/pwd/{userEmail}
public ResponseEntity<Void> checkUserEmail...
참고
Handling ambiguous handler methods mapped in REST application with Spring
I tried to use some code as below: @RequestMapping(value = "/{id}", method = RequestMethod.GET) public Brand getBrand(@PathVariable Integer id) { return brandService.getOne(id); } @RequestMa...
stackoverflow.com
반응형