NutzCN Logo
问答 车牌扫描文件上传出现的问题
发布于 2318天前 作者 shuxinyun 1753 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

我的接收端是如下配置:

@AdaptBy(type = UploadAdaptor.class,  args = { "${app.root}/WEB-INF/tmp"})
    @POST
    @At(value = {"/open/monitor"},top = true)
    @Ok("json")
    public Object monitor(@Param("closeup_pic") TempFile[] files,@Param("..")NutMap data, HttpServletRequest req, AdaptorErrorContext err) {
        try {
            if (err != null && err.getAdaptorErr() != null) {
                return Result.error("文件不合法:" + err.toString());
            } else {
                return Result.success();
                //return upload(type,name,files,data,"image");
            }
        } catch (Throwable e) {
            return Result.error("意外错误:"+e.getMessage());
        }
    }

车牌扫描后,进入try,err不为空有错误,错误信息如下:

[DEBUG] 2018-07-12 14:22:45,002 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'currUser'<class cn.wizzer.app.web.commons.helper.CurrUser>
[WARN ] 2018-07-12 14:22:45,014 org.nutz.mvc.upload.UploadAdaptor.getReferObject(UploadAdaptor.java:197) - Using form upload ? You forgot this --> enctype='multipart/form-data' ?
[INFO ] 2018-07-12 14:22:45,022 org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:261) - Adapter Error catched , but I found AdaptorErrorContext param, so, set it to args, and continue
java.lang.RuntimeException: org.nutz.mvc.upload.UploadException: Unknow Content-Type : application/x-www-form-urlencoded
	at org.nutz.lang.Lang.wrapThrow(Lang.java:187)
	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:254)
	at org.nutz.mvc.upload.UploadAdaptor.adapt(UploadAdaptor.java:120)
	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 cn.wizzer.app.web.commons.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)

不清楚问题出在哪,这样是否没有文件类型限制,请指教

6 回复

客户端文件上传方式无法改变,我们服务端这边接收是否有解决方案?

没选文件的时候报这个错误?

不是,这个文件是车牌扫描系统拍的照片上传给我们的服务端,现在报上面的错误

上传图片时Content-Type application/x-www-form-urlencoded 是不行的, 正确的是multipart/form-data

哦 那就是说客户端那边上传的数据格式不正确,是吧?

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