NutzCN Logo
问答 安卓提交多个文件时出现问题
发布于 2728天前 作者 qq_27cb6638 1632 次浏览 复制 上一个帖子 下一个帖子
标签:

提交一个文件时成功,提交多个时就不行,以下是安卓提交的代码
RequestParams params = new RequestParams(url);
for(int i=0; i<2; i++) {
File f = new File(Environment.getExternalStorageDirectory() + "/test.mp4");
Long time = System.currentTimeMillis();
try {
params.setMultipart(true);
params.addBodyParameter("filedata", f);
params.addBodyParameter("filename", time + ".mp4");
x.http().post(params, new Callback.CommonCallback() {
@Override
public void onSuccess(String result) {
tv_result.setText("onSuccess:" + result);
}
});
} catch (Exception e) {
Log.e("TAG", e.toString());
Toast.makeText(this, "失败", Toast.LENGTH_SHORT).show();
}
}

这是后台报的错

2017-5-27 15:45:57.622 WARN [http-nio-8080-exec-5] Error@/hazards/supplement/add :
java.lang.ClassCastException: java.util.LinkedList cannot be cast to org.nutz.mvc.upload.TempFile
at org.nutz.mvc.upload.injector.TempFileInjector.get(TempFileInjector.java:22)
at org.nutz.mvc.upload.injector.TempFileInjector.get(TempFileInjector.java:1)
at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:242)
at org.nutz.mvc.upload.UploadAdaptor.adapt(UploadAdaptor.java:117)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:64)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:182)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

2 回复

搞定了,谢谢大神

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