Trouble Shooting
[SpringBoot & Postman] HTTP method names must be tokens 오류 해결
깨구르르
2024. 6. 25. 17:02
728x90
1. 오류 내용
더보기
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x000xf70x010x000x000xf30x030x030x19|0x920xbb(G0x86p0xc40xc90xff0x040xa1Q0x1eP0x17h0xab0xfe0xa7&0x000xa26D0xf90x99%0xe10x8f2 ]. HTTP method names must be tokens
2. 기존 MemberController
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class MemberController {
private final MemberMapper mapper;
private final MemberService memberService;
// 이메일 중복 체크
@GetMapping("email/{email}")
public ResponseEntity<Object> emailCheck(@PathVariable(value = "email") String email) {
try {
return new ResponseEntity(memberService.existEmail(email), HttpStatus.OK);
} catch(Exception e) {
e.printStackTrace();
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}
}
}
3. 기존 Postman 요청 url
https://localhost:8080/api/email/springboot@naver.com
4. 문제점 및 해결방법
첫 번째 문제점
MemberController에서 @GetMapping(email/{email})이라고 적은 것이 문제였다.
제대로 된 url이 아니기 때문에 문제가 생긴 것이었다.
email 앞에 슬래쉬를 붙여서
@GetMapping(/email/{email})로 수정해주었다.
두 번째 문제점
Postman에서 요청을 보내는 url을 https라고 적은 것이 문제였다.
https를 통해 요청을 보내려면 토큰이 존재해야 하는데,
현재는 토큰 설정을 해두지 않은 상태이기 때문에 http로 수정을 해주었다.
728x90