本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7584355
建立时间:2006年5月29日




[Spring]Spring集成FileUpload
软件技术,  电脑与网络

lhwork 发表于 2006/6/15 11:12:53

1. project-servlet.xml <!-- MultipartResolver for parsing file uploads, implementation for Commons FileUpload --><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">        <!-- one of the properties available; the maximum file size in bytes -->        <property name="maxUploadSize">            <value>2000000</value>        </property></bean>2. upload.html 500)this.width=500'><form action="" method="post" encType="multipart/form-data">500)this.width=500'><input type="file" name="f">500)this.width=500'><input type="submit">500)this.width=500'></form>3. Controller.java   MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;  MultipartFile multipartFile = multipartRequest.getFile("f");  private final String uploadDir= "uploadDir";  String filePathName = getServletContext().getRealPath(File.separator + uploadDir);  File filePath = new File(filePathName);  if (!filePath.exists()) { filePath.mkdirs(); }  String fileName = filePathName + File.separator + multipartFile.getOriginalFilename();  File file = new File(fileName);  multipartFile.transferTo(file);参考: 1. spring's sample: imagedb2. spring reference


阅读全文(2954) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.955 second(s), page refreshed 144761833 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号