2014. 3. 7. 11:06ㆍFrameWork/Spring
1) ~servlet.xml 에 등록
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000000"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
2) 폼구성
<form name="form1" enctype="multipart/form-data" action="upload">
<input type="file" name="file0">
<input type="file" name="file0">
</form>
3) 컨트롤러
private FileOutputStream fos;
List<MultipartFile> files = multipartReq.getFiles("file0");
for(int i = 0 ; i < files.size() ; i++){
try{
byte []dataFile = upload.getFile().getBytes();
fos = new FileOutputStream(filePath + fileDelim + fileName);
fos.write(dataFile);
}catch(Exception e){
e.printStackTrace();
}finally{
if(fos != null){
try{
fos.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
대충 요딴식으로 구성함~!
'FrameWork > Spring' 카테고리의 다른 글
[Spring] 이미지 , js , css 로딩이 안될 때 (0) | 2014.04.08 |
---|---|
[Spring]@Value (0) | 2014.03.07 |
[Spring] 로그인 Interceptor 처리 (0) | 2014.03.07 |
[Spring]Encoding 설정 (0) | 2014.03.04 |