티스토리 뷰
스프링 프레임워크 환경에서 파일 업로드 시 대략적인 흐름을 작성했습니다.
세부 사항은 추가하면서 작성하면 되겠습니다.
public Map<String, Object> fileUpload(HttpServletRequest request) throws Exception{
Map<String, Object> resultMap = new HashMap<String, Object>();
DateFormat dfFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = new Date();
String toDate = format.dfFormat(nowDate);
String filePath = toDate+"/";
String fullPath=rootPath+filePath;
File file = new File(fullPath);
if(!file.isDirectory){
file.mkdirs();
}
MultipartHttpServletRequest multipart = null;
Enumeration enuParamName = null;
if(request.getContentType() != null && request.getContentType().indexOf("multipart/form-data") > -1){
multipart = (MultipartHttpServletRequest)request;
List<multipartFile> files = multipart.getFiles("");
//파라미터사용시
enuParamName = multipart.getParamterNames();
for(int j=0; j < files.size; j++){
multipartFile = files.get(j);
file = new File(pathFile);
multipartFile.transferTo(file);
paramMap.put("fileNo", fileNo);
}
}
}
세부 사항은 추가하면서 작성하면 되겠습니다.
public Map<String, Object> fileUpload(HttpServletRequest request) throws Exception{
Map<String, Object> resultMap = new HashMap<String, Object>();
DateFormat dfFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = new Date();
String toDate = format.dfFormat(nowDate);
String filePath = toDate+"/";
String fullPath=rootPath+filePath;
File file = new File(fullPath);
if(!file.isDirectory){
file.mkdirs();
}
MultipartHttpServletRequest multipart = null;
Enumeration enuParamName = null;
if(request.getContentType() != null && request.getContentType().indexOf("multipart/form-data") > -1){
multipart = (MultipartHttpServletRequest)request;
List<multipartFile> files = multipart.getFiles("");
//파라미터사용시
enuParamName = multipart.getParamterNames();
for(int j=0; j < files.size; j++){
multipartFile = files.get(j);
file = new File(pathFile);
multipartFile.transferTo(file);
paramMap.put("fileNo", fileNo);
}
}
}
'스프링 프레임워크(Spring Framework)' 카테고리의 다른 글
| [스프링] cannot be resolved to a type (0) | 2018.02.27 |
|---|---|
| [스프링] Spring hello world 예제 (0) | 2017.12.26 |
| 스프링 크론탭 crontab 예약작업 배치파일 실행하는 방법 (0) | 2017.06.26 |
| 자바스크립트 변수명 및 html id name 을 반복변수를 사용해서 변수 이름 만드는 방법 (0) | 2017.06.07 |
| eai 통한 파일 전송시 permission denied - 권한이 없습니다. (0) | 2017.05.22 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- C언어
- proc
- JDBC
- 인포믹스
- 파이썬
- MySQL
- KG
- 플러터
- 스크래핑
- 프로씨
- ocjap
- 파싱
- XE3
- 문자열
- 자바 smtp
- 오라클
- 라이믹스
- xe addon
- 이클립스
- ocajp
- XE
- webix
- 자바
- xe애드온
- esql
- 포인터
- C
- Python
- php
- EC
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함
