NutzCN Logo
问答 上传文件时出现ioc错误
发布于 2530天前 作者 qq_39fcc7a4 1923 次浏览 复制 上一个帖子 下一个帖子
标签:

@At("/uploadZcpdMx")
@AdaptBy(type = UploadAdaptor.class, args = { "ioc:myUpload" })
@Ok("json")
public Object uploadZcpdMx(@Param("uploads") TempFile tf) {
return cwZcpdMxService.uploadFile(tf);
}

报错信息:

org.nutz.ioc.IocException: IocBean[myUpload] For object [myUpload] - type:[class org.nutz.mvc.upload.UploadAdaptor]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.mvc.impl.Loadings.evalObj(Loadings.java:325)
at org.nutz.mvc.impl.processor.AbstractProcessor.evalObj(AbstractProcessor.java:48)
at org.nutz.mvc.impl.processor.AdaptorProcessor.evalHttpAdaptor(AdaptorProcessor.java:37)
at org.nutz.mvc.impl.processor.AdaptorProcessor.init(AdaptorProcessor.java:23)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:201)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:91)
at org.nutz.mvc.NutFilter.init(NutFilter.java:69)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3828)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5616)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349)
at java.lang.Thread.run(Unknown Source)

19 回复

首先, 发代码发日志用 "插入代码或日志片段" 按钮啊!!

然后, 报错信息不全

org.nutz.ioc.IocException: IocBean[myUpload] For object [myUpload] - type:[class org.nutz.mvc.upload.UploadAdaptor]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.mvc.impl.Loadings.evalObj(Loadings.java:325)
	at org.nutz.mvc.impl.processor.AbstractProcessor.evalObj(AbstractProcessor.java:48)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.evalHttpAdaptor(AdaptorProcessor.java:37)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.init(AdaptorProcessor.java:23)
	at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
	at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
	at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:201)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:91)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:69)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3828)
	at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291)
	at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5616)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381)
	at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'myUpload' without define!
	at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:166)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:180)
	... 26 more

Object 'myUpload' without define!主要错误就是这个,我不知道myUpload在哪边定义

我写了个upload.js
var ioc = {
    tmpFilePool : {
        type : 'org.nutz.filepool.NutFilePool',
        // 临时文件最大个数为 1000 个
        args : [ "E:/TestUpLoad", 1000 ]
    },
    uploadFileContext : {
        type : 'org.nutz.mvc.upload.UploadingContext',
        singleton : false,
        args : [ {
            refer : 'tmpFilePool'
        } ],
        fields : {
            // 是否忽略空文件, 默认为 false
            ignoreNull : true,
            // 单个文件最大尺寸(大约的值,单位为字节,即 1048576 为 1M)
            maxFileSize : 1048576,
        // 正则表达式匹配可以支持的文件名
        // nameFilter : '^(.+[.])(xls)$'
        }
    },
    myUpload : {
        type : 'org.nutz.mvc.upload.UploadAdaptor',
        singleton : false,
        args : [ {
            refer : 'uploadFileContext'
        } ]
    }
};

不知道还有哪里没写了

IocBy贴一下

@IocBy(type = ComboIocProvider.class, args = { "*js", "/mvc", "/ioc", "*anno", "com.sys.framework", "com.fzzl","*tx", "*jedis" })

upload.js 放在哪里了??

放在js的包下了

是放的位置不对么?那要放在哪里?

另外,**"/mvc"** 应该是多余的吧

"/mvc" 为啥是多余的?

mvc目录下面放了啥?动作链的配置文件吧?

编译可以通过和了,但是后台获取上传的文件是null

后台日志发一下看看

可以了,是前台的属性写错了,谢谢你的解答,感谢

但是**"/mvc"** 为啥是多余的?

mvc目录下面放了啥嘛? 一般是放动作链的配置文件, 不会放ioc的配置文件

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