오류확인.해결
Current request is not of type [org.springframework.web.multipart.MultipartRequest]
emilyyoo
2024. 4. 16. 00:32
728x90
MultipartFile 타입으로 파라미터 넘겼을 때 오류 3가지 경우의 수.
원인 1. 설정파일(ex) applycation.yml) 에 multipart 관련 설정이 없을 때.
해결 . 아래 처럼 각자의 요구사항에 맞는 설정을 해준다.
servlet:
multipart:
enabled: true
file-size-threshold: 0B
max-request-size: 100MB
max-file-size: 100MB
원인 2. 클라이언트(ex)postman) 에서 content-type 을 잘못 설정한 경우.
해결1-1 : HEADER 를 아래와 같이 해주고.
Content-Type:multipart/form-data
해결1-2 : Body 를 아래와 같이 해준다.
원인3. @RequestMapping 옵션 문제.
해결 : 아래와 같이 옵션을 추가해준다.
consumes = "multipart/form-data")
728x90