프로젝트2 : 통신연결 (메모)

piper ·2023년 11월 23일
0

FormData :
폼 데이터 인터페이스는 폼의 필드와 그들의 값을 나타내는 키/값으로 이루어진 세트를 제공한다. fetch()메서드를 사용해서 보낼 수 있다. 만약 인코딩 타입이 "mutipart/form-data"라면 같은 포멧을 사용하여야 한다.

FormData.append(fieldname, value, (filename)):
Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

참고: https://pobsiz.tistory.com/12
https://flykimjiwon.tistory.com/166

오류
최초에 콘텐츠 타입을 application/json로 보냈을 때
500 오류로

=>2023-11-22 14:54:00.599 ERROR 929 --- [0.0-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is javax.servlet.ServletException: org.apache.tomcat.util.http.fileupload.impl.InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/json] with root cause

이렇게 떠서 콘텐츠타입을' Content-Type': 'multipart/form-data',
이것으로 바꾸었거더니
500 오류는 일단 사라진 상태입니다.
알기로는 모든 정보가 폼데이터로 간 이후에 userInfo 부분은
application/json으로 파싱해준다고 알고 있는데 => JSON.stringify() => 여기 덕분에...

그 후에 난 오류는 아래와 같다.
.w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'request' is not present]

지금 요청은 왔는데

request 키가 없다는거 같아요

해결방법 : https://velog.io/@wish/%EC%84%9C%EB%B2%84%EB%A1%9C-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EB%B3%B4%EB%82%B4%EA%B8%B0

profile
연습일지

0개의 댓글