NutzCN Logo
问答 nutz框架UploadAdaptor上传文件进不去upload方法,直接报错,这是什么问题呀?
发布于 6天前 作者 学习nutz中..... 56 次浏览 复制 上一个帖子
标签:

upload方法:
*/
//
@At("/upload")
@Ok("json")
@AdaptBy(type = UploadAdaptor.class)
public void upload(TempFile file) throws IOException, JSONException, org.json.JSONException {
String tempFileName = file.getSubmittedFileName();
String nmRecId = tempFileName.substring(0, tempFileName.indexOf("-"));
.......

控制台报错:
DEBUG 10:07:26 UrlMappingImpl.get(101)-->Found mapping for [POST] path=/templateAdpterWpsAt/upload : TemplateAdpterWpsAt.upload(TemplateAdpterWpsAt.java:5650)
DEBUG 10:07:26 NutIoc.get(151)-->Get 'templateAdpterWpsAt'<class com.wonders.ghqfg.work.TemplateAdpterWpsAt>
DEBUG 10:07:26 UploadAdaptor.getReferObject(184)-->Select Html4 Form upload parser --> /ghqfgnw/templateAdpterWpsAt/upload
DEBUG 10:07:26 FastUploading.parse(39)-->FastUpload : /templateAdpterWpsAt/upload
DEBUG 10:07:26 FastUploading.parse(54)-->info created
DEBUG 10:07:26 FastUploading.parse(60)-->Params map created - 0 params
DEBUG 10:07:26 FastUploading.parse(77)-->boundary:
--ECPq1XMf8nzzYMKUAkQHTiX9S9HdvrYrqkn
DEBUG 10:07:26 FastUploading.parse(100)-->skip first boundary
DEBUG 10:07:26 FastUploading.parse(111)-->Reading...
DEBUG 10:07:26 FastUploading.parse(133)-->Upload File info: FilePath=[203313-81],fieldName=[file]
DEBUG 10:07:26 FastUploading.parse(137)-->Upload Info: name=203313-81,content_type=multipart/form-data
DEBUG 10:07:26 FastUploading.parse(231)-->...Done 13518 bytes readed
WARN 10:07:26 FailProcessor.process(28)-->Error@/templateAdpterWpsAt/upload :
java.lang.RuntimeException: r u kidding me?! It is impossible!
at org.nutz.lang.Lang.impossible(Lang.java:119)
at com.wonders.ghqfg.work.TemplateAdpterWpsAt$$FASTCLASS._invoke(TemplateAdpterWpsAt.java:1)
at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
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 com.wonders.tiles.processor.SecurityFilterProcessor.process(SecurityFilterProcessor.java:35)
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:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

2 回复

我也是这样改的 ,还是报错了

 @At("/upload")
    @Ok("json")
    @POST
    @AdaptBy(type = UploadAdaptor.class,args = { "ioc:myFileUpload"})
    public void upload(TempFile file) throws IOException, JSONException, org.json.JSONException {
        String tempFileName = file.getSubmittedFileName();
        String nmRecId = tempFileName.substring(0, tempFileName.indexOf("-"));
。。。}

ioc的upload.js:
	myFileUpload : {
		type : 'org.nutz.mvc.upload.UploadAdaptor',
		singleton : false,
		args : [ { refer : 'uploadfileContext' } ]
	},
uploadfileContext : {
		type : 'org.nutz.mvc.upload.UploadingContext',
		singleton : false,
		args : [ { refer : 'tmpFilePool' } ],
		fields : {
		// 是否忽略空文件, 默认为 false
		ignoreNull : true,
		// 单个文件最大尺寸(大约的值,单位为字节,即 1048576000 为 1000M)
		maxFileSize : 1048576000,
		// 正则表达式匹配可以支持的文件名
	      // nameFilter : '^(.+[.]+.+)$'
		}
	},
	tmpFilePool : {
		type : 'org.nutz.filepool.NutFilePool',
		// 临时文件最大个数为 1000 个
		args : [ {java:'$uploadUtils.getPath("/WEB-INF/tmp")'}, 1000 ]
	},



DEBUG 14:25:36 UrlMappingImpl.get(101)-->Found mapping for [POST] path=/templateAdpterWpsAt/upload : TemplateAdpterWpsAt.upload(TemplateAdpterWpsAt.java:5704)
DEBUG 14:25:36 NutIoc.get(151)-->Get 'templateAdpterWpsAt'<class com.wonders.ghqfg.work.TemplateAdpterWpsAt>
DEBUG 14:25:36 UploadAdaptor.getReferObject(184)-->Select Html4 Form upload parser --> /ghqfgnw/templateAdpterWpsAt/upload
DEBUG 14:25:36 FastUploading.parse(39)-->FastUpload : /templateAdpterWpsAt/upload
DEBUG 14:25:36 FastUploading.parse(54)-->info created
DEBUG 14:25:36 FastUploading.parse(60)-->Params map created - 0 params
DEBUG 14:25:36 FastUploading.parse(77)-->boundary:
--KiaWkrn-F3X6XbskbYYyeXt3jPcToLmYsmn77LYT
DEBUG 14:25:36 FastUploading.parse(100)-->skip first boundary
DEBUG 14:25:36 FastUploading.parse(111)-->Reading...
DEBUG 14:25:36 FastUploading.parse(133)-->Upload File info: FilePath=[203281-3],fieldName=[file]
DEBUG 14:25:36 FastUploading.parse(137)-->Upload Info: name=203281-3,content_type=multipart/form-data
DEBUG 14:25:36 FastUploading.parse(231)-->...Done 28921 bytes readed
WARN 14:25:36 FailProcessor.process(28)-->Error@/templateAdpterWpsAt/upload :
java.lang.RuntimeException: r u kidding me?! It is impossible!
at org.nutz.lang.Lang.impossible(Lang.java:119)
at com.wonders.ghqfg.work.TemplateAdpterWpsAt$$FASTCLASS._invoke(TemplateAdpterWpsAt.java:1)
at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
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 com.wonders.tiles.processor.SecurityFilterProcessor.process(SecurityFilterProcessor.java:35)
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:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

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