스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
파일 업로드 부분 수강
Slf4j log cannot be resolved
lombok
라이브러리가 제대로 설치되지 않아서 생기는 문제였다.application.properties
파일에 파일 업로드 관련 설정을 추가했다.
max-file-size
: 파일 1개의 최대 크기
max-request-size
: 멀티파트 요청 하나의 모든 파일 크기 합의 최대값 (기본 10MB)
나는 D드라이브에 파일을 저장하려고 경로에 드라이브까지 적어주었다. D드라이브 파일경로 설정
Windows™: drive:\ProgramFiles\IBM\WebSphere\AppServer
where drive is the system drive on which the file directory is stored. For example: C or D.
spring.servlet.multipart.enabled=false
멀티파트 처리 여부 (기본값 true)
// application.properties
# 파일 업로드 사이즈 제한
spring.servlet.multipart.max-file-size=1MB
spring.servlet.multipart.max-request-size=10MB
# 파일 업로드 경로
file.dir=D:/practice/file/
spring.servlet.multipart.enabled=false
import org.springframework.beans.factory.annotation.Value;
// application.properties의 속성값 그대로 가져오기
@Value("${file.dir}")
String fileDir;
multiple="multiple"