NutzCN Logo
问答 多图片上传问题
发布于 3271天前 作者 qq_B961929188CCD397673F9505827728CB 2386 次浏览 复制 上一个帖子 下一个帖子
标签: dao 上传

XHC__45H39EJ_4_1RGY9CD9_png QQ图片20160108132512_png

多图片上传时,用@Param("..") TempFile[] tf 适配多个图片出错

8 回复
@Param("file")TempFile[] tmps

如果不确定有哪些名字

@Param("..")Map<String,Object> params

因为要上传多个文件,所以名字不能确定,除了同时上传了多图片,还带了其他form表单
Map<String, String> textMap = new HashMap<String, String>();

    Map<String, String> fileMap = new HashMap<String, String>(); 
    fileMap.put("FilePath",filepath );
    fileMap.put("FilePath1",filepath );
    fileMap.put("FilePath2",filepath );
    fileMap.put("FilePath3",filepath );
    String ret = HttpPostUploadUtil.formUpload(urlStr, textMap, fileMap);

public Object editProject(@Param("..") Project project,@Param("projLogo")TempFile projLogo,@Param("pirture1")TempFile pirture1,@Param("pirture2")TempFile pirture2,@Param("pirture3")TempFile pirture3,
AdaptorErrorContext err) {
String msg ="";
return super.ajaxOk(project,"更新成功");
}

上传多张图片,这样多个TempFile接收是不行的,除了第一个TempFile能接收到,其他TempFile都为空

贴后台的解析日志

2016-10-18 14:46:26,061 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:92) DEBUG - Found mapping for [POST] path=/project/addProject : ProjectAction.addProject(ProjectAction.java:55)
2016-10-18 14:46:26,061 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'projectAction'<class com.cs.base.action.project.ProjectAction>
2016-10-18 14:46:26,062 org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:187) DEBUG - Select Html4 Form upload parser --> /UEcoopera/project/addProject
2016-10-18 14:46:26,066 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:39) DEBUG - FastUpload : /project/addProject
2016-10-18 14:46:26,068 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:54) DEBUG - info created
2016-10-18 14:46:26,068 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:60) DEBUG - Params map created - 0 params
2016-10-18 14:46:26,069 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:77) DEBUG - boundary:
-----------------------------3670683213765
2016-10-18 14:46:26,073 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:100) DEBUG - skip first boundary
2016-10-18 14:46:26,073 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:111) DEBUG - Reading...
2016-10-18 14:46:26,074 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[id]
2016-10-18 14:46:26,074 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[id] value=[]
2016-10-18 14:46:26,074 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[projName]
2016-10-18 14:46:26,074 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[projName] value=[123]
2016-10-18 14:46:26,075 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[Batman.png],fieldName=[projLogo]
2016-10-18 14:46:26,075 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) DEBUG - Upload Info: name=Batman.png,content_type=image/png
2016-10-18 14:46:26,090 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[projAd]
2016-10-18 14:46:26,090 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[projAd] value=[4]
2016-10-18 14:46:26,090 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[projDesc]
2016-10-18 14:46:26,091 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[projDesc] value=[5]
2016-10-18 14:46:26,091 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[projType]
2016-10-18 14:46:26,091 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[projType] value=[6]
2016-10-18 14:46:26,092 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[Cloud.png],fieldName=[picture1]
2016-10-18 14:46:26,092 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) DEBUG - Upload Info: name=Cloud.png,content_type=image/png
2016-10-18 14:46:26,096 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[Car.png],fieldName=[picture2]
2016-10-18 14:46:26,096 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) DEBUG - Upload Info: name=Car.png,content_type=image/png
2016-10-18 14:46:26,099 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[],fieldName=[picture3]
2016-10-18 14:46:26,099 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:137) DEBUG - Upload Info: name=,content_type=application/octet-stream
2016-10-18 14:46:26,099 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:133) DEBUG - Upload File info: FilePath=[null],fieldName=[detailDesc]
2016-10-18 14:46:26,100 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:214) DEBUG - Found a param, name=[detailDesc] value=[]
2016-10-18 14:46:26,100 org.nutz.mvc.upload.FastUploading.parse(FastUploading.java:230) DEBUG - ...Done 1008411 bytes readed

单词写错了 pirture1 应该是 picture1

艾玛,真不好意思,犯了个这么低级的错误

添加回复
请先登陆
回到顶部