0

此代码片段在被 websphere 服务器调用时工作正常(cl 的类型为 com.ibm.ws.classloader.CompoundClassLoader)。

ClassLoader cl = Thread.currentThread().getContextClassLoader();
Enumeration resenum = cl.getResources("/abc.xml");

但是,当我从 main 方法在独立类中运行相同的代码时(通过将 abc.xml 的文件夹路径添加到运行时配置), resnum 为空。cl 是 sun.misc.Launcher$AppClassLoader 类型。如果我从代码中删除“/”,它工作正常。有没有办法可以在 abc.xml 之前加载一个“/”(可能使用其他一些类加载器)?请帮忙。

4

0 回答 0