728x90
problem
HttpMediaTypeNotAcceptableException : No acceptable representation
406
Post 메서드 에서 응답 헤더 불일치 에러가 발생했다
응답도 잘 나오고 디버깅해도 서블릿단까지 가서 에러가 났다.
solution
문제의 코드를 보면
import org.springframework.http.MediaType
@PostMapping("/customer/board", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun register(
req: .......,
@RequestPart(value = "files", required = false) files : List<MultipartFile>?,
): ResponseEntity<BaseResp> {
return ...
)
}
파일을 받아오는 Post메서드이다.
얼핏보면 문제가 없지만 consumes 에 미디어 타입을 MediaType 상수에서 문자열로 변환하기 전에
서블릿에서 인식하지 못하여 발생하였다
@PostMapping("/customer/board", consumes = ["multipart/form-data"])
fun register(
req: .......,
@RequestPart(value = "files", required = false) files : List<MultipartFile>?,
): ResponseEntity<BaseResp> {
return ...
)
}
문자열로 바꿔주어서 해결 하였다.
728x90
'일-상 > 오류노트' 카테고리의 다른 글
[오류노트] QueryDSL 의 NoSuchMethodError (0) | 2025.01.15 |
---|---|
[오류노트] S3 이미지 URL 조회 권한 오류 (0) | 2024.11.13 |
[IntelliJ] 인텔리제이 메모리 점유율 낮추기 (0) | 2024.11.04 |
[오류노트] github Actions / ssh: unable to authenticate (0) | 2024.10.19 |
[오류노트] 실패한 요청을 재시도 하지 말자 DeadLetter queue (0) | 2024.09.05 |