[Error] org.springframework.web.multipart.support.MissingServletRequestPartException

SangDosa·2024년 4월 25일

Error

목록 보기
4/5

오류

param이 있는 Http 통신 테스트 진행 시 아래 오류 발생

org.springframework.web.multipart.support.MissingServletRequestPartException

해결방안

호출되는 Http method의 param 값이 없을 경우 테스트 오류 발생하기 때문에 param 값이 안들어 왔을 경우에 대한 속성(required = false) 추가를 해준다.

AS-IS

    @PostMapping("/chunk/upload")
    public ResponseEntity<String> chunkUpload(@RequestParam(name = "chunk") MultipartFile file,
                                              @RequestParam("chunkNumber") int chunkNumber,
                                              @RequestParam("totalChunks") int totalChunks) throws IOException {
                                              '''

TO-BE

    @PostMapping("/chunk/upload")
    public ResponseEntity<String> chunkUpload(@RequestParam(name = "chunk", required = false) MultipartFile file,
                                              @RequestParam("chunkNumber") int chunkNumber,
                                              @RequestParam("totalChunks") int totalChunks) throws IOException {
                                              '''
profile
조용한 개발자

0개의 댓글