NutzCN Logo
问答 文件上传后台File接收为null,Unknow Content-Type
发布于 2703天前 作者 thekingdk 4321 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.mvc.upload.UploadException: Unknow Content-Type : application/x-www-form-urlencoded
不知道这个是需要在哪里设置???input标签上已加enctype属性:

2017-07-29 14:37:44,396 org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:197) WARN  - Using form upload ? You forgot this --> enctype='multipart/form-data' ?
2017-07-29 14:37:44,397 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/api/v1/template/paperTemplateInsert :
java.lang.RuntimeException: org.nutz.mvc.upload.UploadException: Unknow Content-Type : application/x-www-form-urlencoded
	at org.nutz.lang.Lang.wrapThrow(Lang.java:184)
	at org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:202)
	at org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:62)
	at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:226)
	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:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.iflytek.tst.rms.chain.JwtChainProcess.process(JwtChainProcess.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:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.iflytek.tst.rms.common.filter.CorsFilter.doFilter(CorsFilter.java:48)
	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:505)
	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:534)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:277)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2381)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2370)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.mvc.upload.UploadException: Unknow Content-Type : application/x-www-form-urlencoded
	at org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:199)
	... 40 more

10 回复

应该加在 <form> 上吧

来自美丽的 NutzCN

前端用的vue,没有form啊....

用了@AdaptBy(type = WhaleAdaptor.class) 是不报Caused by: org.nutz.mvc.upload.UploadException: Unknow Content-Type : application/x-www-form-urlencoded这个了,但是文件参数还是null

VUE 不熟,总之,你提交的 <form> 必须加那个属性,否则得不到。这个是 HTTP 的标准
你搜搜 VUE 相关的解决方法咯,肯定有其他人碰到这个问题的

又妄想用ajax上传文件?

@wendal 似乎vue都是Ajax提交。。。

vue核心没有ajax哦,都是扩展库的事,你需要找的是ajaxfileupload,百度谷歌欢迎你

webupload,七牛,也是不错的选择

@thekingdk 我想问一下 用vue 最后咋解决的。。

@wendal element-ui 自带的 文件上传可以吗

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