jsp 에서 multipart/form-data 을 확인한다.
<form:form modelAttribute="boardVO" method="post"action="/notice/insert" enctype="multipart/form-data">
servletr-context 에
<!-- 첨부파일을 처리하는 빈 설정 -->
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.support.StandardServletMultipartResolver"></beans:bean>
controller 에 @Autowired FileUpload fileUpload; 를 해준다 (util 에 FileUpload.java 있음)
/* 파일 업로드 */
MultipartFile[] uploadFile = boardVO.getUploadFile(); //boardVO에서 uploadFile을 가져오고
String path = "notice"; // util 에 FileUpload.java 에서 path 경로를 정해준다
String atchRelId = boardVO.getBrdId(); // atchRelId 에 boardVO의 BrdId 를 넣어준다
List<String> insertFileNames = fileUpload.insert(path, uploadFile, atchRelId);
// util 에 FileUpload.java 에 insert 메서드에 path, uploadFile, atchRelId 정보를 넣는다
FileUpload.java - AttachMapper - AttachVO - Attach_SQL 흐름을 읽는다.
'개발자 > 최종프로젝트' 카테고리의 다른 글
| 20220317 the server cannot be started because one or more of the ports are invalid. open the server editor and correct the invalid ports. (0) | 2022.03.17 |
|---|---|
| 20220316 파일 다운로드 구현 (0) | 2022.03.16 |
| 20220316 아파치 톰캣 연동 (0) | 2022.03.16 |
| 20220316 인코딩 설정 (0) | 2022.03.16 |
| 20220316 패키지 익스플로러 보기 쉽게 하기 (0) | 2022.03.16 |