오류 뜬 것

coding S's avatar
Apr 19, 2024
오류 뜬 것

[ 컨트롤러에 똑같은 url이 2개 ]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Ambiguous mapping. Cannot map 'replyController' method shop.mtcoding.blog.model.reply.ReplyController#delete(Integer) to {DELETE [/api/replies/{id}]}: There is already 'replyApiController' bean method shop.mtcoding.blog.model.reply.ReplyApiController#delete(Integer) mapped.
 

[ @RequestParam은 json으로 파싱 불가! 터짐! ]

@PostMapping("/users/join") public ResponseEntity<?> join(@RequestParam(name = "role") Integer role, @RequestBody UserRequest.JoinDTO reqDTO) { User user = userService.join(reqDTO, role); session.setAttribute("sessionUser", user); return ResponseEntity.ok(new ApiUtil(user)); }
"org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'role' for method parameter type Integer is not present\r\n\tat org.springframework.web.method.annotation. RequestParamMethodArgumentResolver.handleMissingValueInternal (RequestParamMethodArgumentResolver.java:217)\r\n\tat org.springframework.web.method.annotation.RequestParamMethodArgumentResolver. handleMissingValue(RequestParamMethodArgumentResolver.java:193)
방법 1 : URL에 쿼리 파라미터로 포함시키기 방법 2 : role을 JSON 본문에 포함시키고, @RequestParam 대신 @RequestBody를 사용하여 복합 객체로 받기
Share article

codingb