在DAOFactory类里写个
String path;
Document doc = new SAXReader().read(new file(path+"/daoContext.xml"));
daoContext.xml文件在WEB-INF目录下
path路径怎么写?
尝试:
“/WEB-INF”
“WEB-INF”
“../WEB-INF”
都不对
URL url = DAOFactory.class.getClassLoader().getResource(".");
String path = new File(url.getFile()).getParent() + "/WEB-INF";
Document doc = new SAXReader().read(new File(path+"/daoContext.xml"));
URL url = DAOFactory.class.getClassLoader().getResource(".");
String path = new File(url.getFile()).getParent() + "/WEB-INF";
Document doc = new SAXReader().read(new File(path+"/daoContext.xml"));
path 指的是你的class路径吧 你得看看你class文件放到哪儿了
找到class 然后吧daoContext.xml 加进去
多试几次实践出来!