No HttpMessageConverter 에러해결

Jinjin·2023년 11월 10일
0
post-thumbnail

Content-Type

📌ERROR
org.springframework.web.client.RestClientException: No HttpMessageConverter for org.springframework.util.LinkedMultiValueMap and content type "image/gif"

서버와 클라이언트가 어떤 자원(파일, 문서, 데이터 등)을 주고 받을 때 웹 서버는 HTTP헤더로 파일이나 자원을 포함하는 바이트의 Stream을 앞에 보낸다. 예를 들어, 헤더는 사용되고 있는 웹 서버의 'SW타입', '서버의 날짜와 시간', 'HTTP 프로토콜', '사용중인 커넥션 타입' 등을 지정한다.

Content-Type 개체 헤더는 리소스의 Media Type을 나타내기 위해 사용된다.

⚠ Response안에 "Content-Type" 헤더는 클라이언트에게 반환된 컨텐츠 유형이 실제로 무엇인지 알려준다.
⇒ 나는 여기서 gif파일을 전송하기 때문에MediaType.IMAGE_GIF로 생각했는데 서로 데이터를 통신할 때 MultipartFile로 하기 때문에 MediaType.MULTIPART_FORM_DATA로 설정해야했다.

참고 : https://dev-gorany.tistory.com/125


maxPostSize 에러

📌ERROR
java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector

발생한 이유는 파라미터 개수가 설정 해놓은 톰캣은 기본적으로 max post size가 2MB로 지정되어있다. 하지만, 기존에 설정되어있는 max post size보다 큰 용량의 데이터를 전송하려면 설정을 바꿔야한다.
아니면... 저와 같은 에러가... 발생해요~~

해결방법:

server:
  tomcat:
    max-http-form-post-size: 20MB

MultipartFile이 담기지 않는 경우

<2023-11-07T16:38:58.085+09:00  WARN 2716 --- [nio-8400-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required part 'gifFile' is not present.]

https://green-bin.tistory.com/44

<2023-11-07T16:51:52.739+09:00  WARN 2716 --- [nio-8400-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required part 'gifFile' is not present.]
2023-11-07T16:51:52.740+09:00  WARN 2716 --- [nio-8400-exec-6] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: No acceptable representation]

https://vvh-avv.tistory.com/230

profile
BE Developer

0개의 댓글