我自定义了一个实现了ServletContextListener接口的监听器(MyListener),
读取xml文件。
web.xml的配置如下
 <context-param>
   <param-name>contextConfigLocation</param-name>
     <param-value>config/test.xml</param-value>
  </context-param>
 <listener>
   <listener-class>com.lyq.action.MyListener</listener-class>
  </listener>其中config/test.xml在classpath即src下可是在MyListener中为什么取得路径是错误的呢。source如下:
String configurationLocation = context.getInitParameter("contextConfigLocation");
SAXReader reader = new SAXReader(); 
Document doc = reader.read(configurationLocation);  //用dom4j读取错误如下:
D:\MyLucy\eclipse\config\test.xml (系统找不到指定的路径。) Nested exception: D:\MyLucy\eclipse\config\test.xml (系统找不到指定的路径。)请那为大人告诉我一下,如何取得正确的路径名:
例如:e:\work\workspace\testPJ\src\config\test.xml谢谢!!!!!