想利用MultipartRequest的getFileName方法来一次获取多个上传的文件名字时,得到的不是文件的名字,而是 input 的name属性
最后找到了答案,解决方法,参照http://stackoverflow.com/questions/13946859/retrieve-the-file-name-while-using-file-type-input
原来的代码
@RequestMapping(value = {"multipleFileUpload"}, method = {RequestMethod.GET, RequestMethod.POST})
public String multipleFileUpload(
ModelMap modelMap,
MultipartHttpServletRequest request,
HttpServletResponse response) throws IOException {
Iterator<String> itr = request.getFileNames();
while(itr.hasNext()){
String str = itr.next(); //这个文件并不是原来的文件名
multipartFile = (CommonsMultipartFile)request.getFile(str);
MultipartFile mpf = request.getFile(str);
InputStream is = mpf.getInputStre