81,119
社区成员
发帖
与我相关
我的任务
分享
<form action="icon/upload" method="post" id="iconForm" enctype="multipart/form-data">
<table">
<tr>
<td>头像</td>
<td><input id="iconImg" name="iconImg" type="file" /></td>
<td><input type="submit" value="上传"/></td>
</tr>
</table>
</form>
@RequestMapping(value = URI_COURIER_ICON_UPLOAD,method = RequestMethod.POST)
public String iconUpload(MultipartFile iconImg,HttpServletRequest request,String aas ){
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file1 = multipartRequest.getFile("iconImg");
Map<String,MultipartFile> fileMap =multipartRequest.getFileMap();}
<a href="http://bbs.csdn.net/topics/390803763" >这就对了应该!</a>
配置文件中添加:
<!-- id="multipartResolver"必须是multipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- maxUploadSize:文件上传的最大值以byte为单位 -->
<property name="maxUploadSize" value="1024000"></property>
</bean>
只有这样springMVC才会解析到你上传的文件的。如果你不喜欢这种方式你可以使用commons-fileupload