반응형
파일 업로드를 하기 위해서 아래 라이브러리를 추가해준다.
1
2
3
4
5
|
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
|
cs |
ServletConfig.java에 Bean을 추가해 준다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
@Bean(name="multipartResolver")
public CommonsMultipartResolver getResolver() throws IOException {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
//한번에 Request로 전달될 수 있는 최대의 크기
resolver.setMaxUploadSize(1024 * 1024 * 10);
//하나의 파일 최대 크기
resolver.setMaxUploadSizePerFile(1024 * 1024 * 2);
//메모리상에서 유지하는 최대의 크기
resolver.setMaxInMemorySize(1024 * 1024);
//일정 크기 이상의 데이터는 아래 임시 파일에 임시파일로 저장
resolver.setUploadTempDir(new FileSystemResource("D:\\upload\\tmp"));
resolver.setDefaultEncoding("UTF-8");
return resolver;
}
|
cs |
반응형
'Spring > IntelliJ 설정' 카테고리의 다른 글
[IntelliJ] 한글설정 (0) | 2020.07.08 |
---|---|
[IntelliJ] 04 - Controller (0) | 2020.07.08 |
[IntelliJ] 03 - 인텔리제이 MyBatis 연동 (0) | 2020.07.06 |
[IntelliJ] 02 - 인텔리제이 데이터베이스 연동 (0) | 2020.07.06 |
[IntelliJ] 01 - 인텔리제이 환경설정 (0) | 2020.07.06 |