NutzCN Logo
问答 shoul d be a directory or don't have permission to create it!
发布于 1461天前 作者 啊哈 1545 次浏览 复制 上一个帖子 下一个帖子
标签:

2020-12-21 12:44:53:[DEBUG][ org.nutz.mvc.impl.NutActionChainMaker.eval(NutActio
nChainMaker.java:51)] [org.nutz.mvc.impl.NutActionChainMaker]:Eval FAIL!! : publ
ic java.lang.Object com.yyt.cos.mvc.MvcAction.html(java.lang.String,java.lang.St
ring,java.lang.String,javax.servlet.http.HttpServletRequest,javax.servlet.http.H
ttpServletResponse,javax.servlet.http.HttpSession,javax.servlet.ServletContext,o
rg.nutz.lang.util.NutMap)
org.nutz.lang.born.BorningException: Fail to born or cast to 'com.yyt.sys.plug.M
yUploadAdaptor'
by args: [@({"charset":"UTF-8","filePool":{"proxy":{"home":{},"cursor":0,"size"
:1000}},"bufferSize":8192,"ignoreNull":true,"maxFileSize":8388608,"nameFilter":"
^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","contentTy
peFilter":null,"nameFilterPattern":{"pattern":"^(.+[.])(doc|docx|txt|xls|xlsx|jp
g|png|gif|jpeg|bmp|zip|rar|7z|tag)$","flags":0}})]
because:java.lang.RuntimeException: '{"charset":"UTF-8","filePool":{"proxy":{"h
ome":{},"cursor":0,"size":1000}},"bufferSize":8192,"ignoreNull":true,"maxFileSiz
e":8388608,"nameFilter":"^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip
|rar|7z|tag)$","contentTypeFilter":null,"nameFilterPattern":{"pattern":"^(.+[.])
(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","flags":0}}' shoul
d be a directory or don't have permission to create it!
at org.nutz.lang.born.ConstructorCastingBorning.born(ConstructorCastingB
orning.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:78)
at org.nutz.ioc.ObjectProxy.get(ObjectProxy.java:69)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:260)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:270)
at org.nutz.mvc.impl.Loadings.evalObj(Loadings.java:334)
at org.nutz.mvc.impl.processor.AbstractProcessor.evalObj(AbstractProcess
or.java:48)
at org.nutz.mvc.impl.processor.AdaptorProcessor.evalHttpAdaptor(AdaptorP
rocessor.java:34)
at org.nutz.mvc.impl.processor.AdaptorProcessor.init(AdaptorProcessor.ja

var ioc = {
tmpFilePool : {
type : 'org.nutz.filepool.NutFilePool',
// 临时文件最大个数为 1000 个
args : [ "${app.root}/WEB-INF/tmps", 10000 ]
},
uploadFileContext : {
type : 'org.nutz.mvc.upload.UploadingContext',
singleton : false,
args : [ { refer : 'tmpFilePool' } ],
fields : {
// 是否忽略空文件, 默认为 false
ignoreNull : true,
// 单个文件最大尺寸(大约的值,单位为字节,即 1048576 为 1M)
maxFileSize : 3145728,
// 正则表达式匹配可以支持的文件名
nameFilter : '^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|pdf)$'
}
},
myUpload : {
type : 'com.yyt.sys.plug.MyUploadAdaptor',
singleton : false,
args : [ { refer : 'uploadFileContext' } ]
}
};

MyUploadAdaptor

public class MyUploadAdaptor extends UploadAdaptor {

Log log=Logs.get();
public MyUploadAdaptor() throws IOException {
    super();
}
public MyUploadAdaptor(String filePath) {
    super(filePath);
}

@Override
public Map<String, Object> getReferObject(ServletContext sc,
       HttpServletRequest request, HttpServletResponse response,
       String[] pathArgs) {

////////
}

4 回复

无权限写${app.root}/WEB-INF/tmps,改个绝对路径

我各种路径都试了还是不行,不知道是不是我自己写的MyUploadAdaptor的问题。
org.nutz.lang.born.BorningException: Fail to born or cast to 'com.yyt.sys.plug.MyUploadAdaptor'
 by args: [@({"charset":"UTF-8","filePool":{"proxy":{"home":{"path":"D:\\tmps\\files"},"cursor":0,"size":1000}},"bufferSize":8192,"ignoreNull":true,"maxFileSize":8388608,"nameFilter":"^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","contentTypeFilter":null,"nameFilterPattern":{"pattern":"^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","flags":0}})]
 because:java.lang.RuntimeException: '{"charset":"UTF-8","filePool":{"proxy":{"home":{"path":"D:\\tmps\\files"},"cursor":0,"size":1000}},"bufferSize":8192,"ignoreNull":true,"maxFileSize":8388608,"nameFilter":"^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","contentTypeFilter":null,"nameFilterPattern":{"pattern":"^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$","flags":0}}' should be a directory or don't have permission to create it!
	at org.nutz.lang.born.ConstructorCastingBorning.born(ConstructorCastingBorning.java:23)

不知道是不是 
myUpload : {
 type : 'com.yyt.sys.plug.MyUploadAdaptor',这个类是我自己写的
 singleton : false,
 args : [ { refer : 'uploadFileContext' } ]
 }


MyUploadAdaptor详情:
/**
 * 系统文件统一插件
 * @author Administrator
 *
 */
public class MyUploadAdaptor extends UploadAdaptor {
	Log log=Logs.get();
	public MyUploadAdaptor() throws IOException {
		super();
	}
	public MyUploadAdaptor(String filePath) {
		super(filePath);
		System.out.println(filePath);
	}
	@Override
	public Map<String, Object> getReferObject(ServletContext sc,
			HttpServletRequest request, HttpServletResponse response,
			String[] pathArgs) {
}
	
var upload = {
		tmpFilePool : {
		    type : 'org.nutz.filepool.NutFilePool',
		    // 临时文件最大个数为 1000 个
		    args : [ "D:/tmps/files", 1000 ]   
		},
		uploadFileContext : { 
		    type : 'org.nutz.mvc.upload.UploadingContext',
		    singleton : false,
		    args : [ { refer : 'tmpFilePool' } ],
		    fields : {
		        // 是否忽略空文件, 默认为 false
		        ignoreNull : true,
		        // 单个文件最大尺寸(大约的值,单位为字节,即 1048576 为 1M)
		        maxFileSize : 8388608,
		        // 正则表达式匹配可以支持的文件名
		        nameFilter : '^(.+[.])(doc|docx|txt|xls|xlsx|jpg|png|gif|jpeg|bmp|zip|rar|7z|tag)$' 
		    } 
		},
		myUpload : {
		    type : 'com.yyt.sys.plug.MyUploadAdaptor',
		    singleton : false,
		    args : [ { refer : 'uploadFileContext' } ] 
		}
};

构造方法要跟args对应

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