Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 자바
- asp.net
- json
- JavaScript
- DML
- MySQL
- SQL
- Spring_에러정리
- SQL_용어정리
- spring
- HTML
- CSS
- Git_정리
- 인스턴스
- github
- 배열
- 아파치톰캣
- Linux_명령어정리
- java
- vb.net
- 이클립스
- Spring_오류정리
- Git_명령어정리
- 다이어그램
- 인덱스
- workbench
- jsp
- git
- Linux
- 자바스크립트
Archives
- Today
- Total
데브마우스
[Spring] 파일 업로드 개요 정리 본문
스프링 파일 업로드란 무엇인가요?
웹 브라우저를 통해 모두 사진이나 파일을 업로드 해본 경험이 있을것입니다. 그렇다면 스프링 프레임워크에서 파일을 업로드 하기 위해서는 어떻게 해야할까요? 이번 포스팅에서 알아보도록 하겠습니다.
스프링 파일 업로드를 하기 위해서는 무엇이 필요한가요?
파일 업로드를 위해서는 2가지 준비가 필요합니다.
pom.xml 파일에 의존 라이브러리 등록하기
<!-- 파일 업로드를 위한 의존 라이브러리-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
servlet-context.xml 파일에 시큐리티 필터 등록하기
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize" value="100000" />
<beans:property name="defaultEncoding" value="utf-8" />
<beans:property name="uploadTempDir" ref="uploadDirResource"/>
</beans:bean>
<beans:bean id="uploadDirResource" class="org.springframework.core.io.FileSystemResource">
<beans:constructor-arg value="c:/upload/"/>
</beans:bean>
파일 업로드를 위한 폼 태그 양식
웹 브라우저에서 서버로 파일을 전송하기 위해서는 JSP 페이지와 JSP 페이지에 form 태그가 필요합니다. form 태그 형식은 아래와 같습니다.
<form method="POST" enctype="multipart/form-data">
<input type="file" name="요청 매개변수 이름">
</form>
'Spring > Spring: 정리' 카테고리의 다른 글
[Spring] Log4j의 logger 로깅 레벨 정리 (0) | 2024.01.24 |
---|---|
[Spring] Log4j 개요 및 작성 순서 정리 (0) | 2024.01.24 |
[Spring] 스프링 시큐리티 개요 정리 (0) | 2024.01.22 |
[Spring] 매트릭스 변수와 @Matrix Varaible 정리 (0) | 2024.01.19 |
[Spring] 경로 변수와 @PathVariable 정리 (0) | 2024.01.19 |