NutzCN Logo
问答 文件上传然后用easypoi解析报错
发布于 2380天前 作者 zp8821138 2047 次浏览 复制 上一个帖子 下一个帖子
标签:

代码如下

@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp", "8192", "utf-8" })
	@At("/verifyExcel")
	@Ok("raw")
	public void verifyExcel(@Param("file") TempFile tmpFile){
		List<VoucherEntity> list;
		try {
			list = FileUtil.importExcel(tmpFile.getInputStream(), 0, 2, VoucherEntity.class);
			System.out.println(list.size());
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

错误如下

18-06-22 15:29:26.561
 WARN [http-apr-18080-exec-5] Error@/platform/voucher/verifyExcel :
java.lang.NullPointerException
	at com.kanq.controller.VoucherController.verifyExcel(VoucherController.java:83)
	at com.kanq.controller.VoucherController$FM$verifyExcel$4184cac2976d6a160b773ebd9efcd06d.invoke(VoucherController.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:744)
18-06-22 15:29:52.539 DEBUG [http-apr-18080-exec-7] Found mapping for [GET] path=/platform/voucher/index : VoucherController.index(VoucherController.java:46)
18-06-22 15:29:52.540 DEBUG [http-apr-18080-exec-7] Get 'voucherController'<class com.kanq.controller.VoucherController>
18-06-22 15:29:59.932 DEBUG [http-apr-18080-exec-2] Found mapping for [POST] path=/platform/voucher/verifyExcel : VoucherController.verifyExcel(VoucherController.java:83)
18-06-22 15:29:59.932 DEBUG [http-apr-18080-exec-2] Get 'voucherController'<class com.kanq.controller.VoucherController>
18-06-22 15:29:59.933 DEBUG [http-apr-18080-exec-2] Select Html4 Form upload parser --> /nutz/platform/voucher/verifyExcel
18-06-22 15:29:59.933 DEBUG [http-apr-18080-exec-2] FastUpload : /platform/voucher/verifyExcel
18-06-22 15:29:59.933 DEBUG [http-apr-18080-exec-2] info created
18-06-22 15:29:59.934 DEBUG [http-apr-18080-exec-2] Params map created - 0 params
18-06-22 15:29:59.934 DEBUG [http-apr-18080-exec-2] boundary: 
------WebKitFormBoundaryowp1LRyCWcatEbhW
18-06-22 15:29:59.935 DEBUG [http-apr-18080-exec-2] skip first boundary
18-06-22 15:29:59.935 DEBUG [http-apr-18080-exec-2] Reading...
18-06-22 15:29:59.936 DEBUG [http-apr-18080-exec-2] Upload File info: FilePath=[test (5).xls],fieldName=[file]
18-06-22 15:29:59.936 DEBUG [http-apr-18080-exec-2] Upload Info: name=test (5).xls,content_type=application/vnd.ms-excel
18-06-22 15:29:59.943 DEBUG [http-apr-18080-exec-2] ...Done 85704 bytes readed
18-06-22 15:30:18.229
 WARN [http-apr-18080-exec-2] Error@/platform/voucher/verifyExcel :
java.lang.RuntimeException: java.lang.IllegalArgumentException
	at com.kanq.common.FileUtil.importExcel(FileUtil.java:185)
	at com.kanq.controller.VoucherController.verifyExcel(VoucherController.java:83)
	at com.kanq.controller.VoucherController$FM$verifyExcel$4184cac2976d6a160b773ebd9efcd06d.invoke(VoucherController.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	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:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:744)

这个方法FileUtil.importExcel(tmpFile.getInputStream(), 0, 2, VoucherEntity.class);在本地测试传入一个文件是没有错的。这个是文件没有完全上传就解析的原因吗?但是貌似很难判断文件上传完成把。

6 回复

上传完成才会进入口方法

怎么判断上传完成呢?

判断? 判断啥?

上传完成才进入入口方法 我怎么判断上传完成呢?

跑你的代码的时候, 是已经上传完成的

是自己傻逼了。代码有点问题。

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