【发布时间】:2015-01-16 06:09:56
【问题描述】:
我正在使用 Windows 8 中的 CQ5.6.1。我正在使用部署在 OSGi 包中的 servlet。从 servlet,我试图打开一个 xml 文件,该文件存储在 CQ 的路径 /etc/clientlibs/geometrixx 中。这是我用来阅读的代码。
import javax.xml.parsers.DocumentBuilderFactory;
...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document amSetupDoc = null ;
amSetupDoc = factory.newDocumentBuilder().parse(new File("/etc/clientlibs/geometrixx/am/BaseAMStock_Settings.xml"));
此时,我收到以下异常。
java.io.FileNotFoundException: D:\etc\clientlibs\geometrixx\am\BaseAMStock_Settings.xml (The system cannot find the path specified)
我不知道为什么路径被转换为 Windows 路径。有没有更好的方法从我的 servlet 读取 CQ 存储库中的文件?我很感激你能给我的任何建议。谢谢。
【问题讨论】:
-
有不同的方法可以从流中读取文件,你用谷歌搜索过吗?你可以参考这个wemblog.com/2011/10/how-to-read-external-file-in-cq.html
标签: xml servlets aem filenotfoundexception osgi-bundle