spring里这样
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext-*.xml");可以获得所有applicationContext-开头的xml文件,我现在用dom4j来做只知道
SAXReader sax = new SAXReader();
URL xmlpath = this.getClass().getClassLoader().getResource("test.xml");
Document doc = sax.read(xmlpath);
来读取单个文件,怎么实现sping那种*的读取呢?
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext-*.xml");可以获得所有applicationContext-开头的xml文件,我现在用dom4j来做只知道
SAXReader sax = new SAXReader();
URL xmlpath = this.getClass().getClassLoader().getResource("test.xml");
Document doc = sax.read(xmlpath);
来读取单个文件,怎么实现sping那种*的读取呢?
要不就翻开SPRING 的源码看看不就行了
spring获得xml文件和用SAX解析xml文件应该不同吧 没有多思考过 不过单从结果来看 spring读取后对类进行加载 并把对象存在容器中 但是SAX解析只是获得xml文件内容吧。
请教!!请教!!
另外,你这个获得XML也是由构造该当取得的有不同的构造方法,也是有默认的,如果不是app***.xml就用其它的因为有*,所以它截取了*的位置,然后搜索目录下有文件.