0

我如何从 ZUL 中的 web-inf 获取 file.xml 的真实路径,我试试这个:

org.zkoss.zrss.RssFeed feed;
org.zkoss.zrss.RssBinder binder = new org.zkoss.zrss.RssBinder();

try {
    feed = binder.lookUpFeed(new File("/WEB-INF/lesscoutsBeRss.xml").toURI().toURL().toString());
} catch (Exception e) {
    e.getStackTrace();
}

但我有问题,我认为问题是因为不好的恢复路径

Failed to load /MainPage/rss_lesscouts.zul

Cause: Null Pointer in Method Invocation
java.lang.NullPointerException: Null Pointer in Method Invocation
    at bsh.Name.invokeMethod(Unknown Source)
    at bsh.BSHMethodInvocation.eval(Unknown Source)
    at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
    at bsh.BSHPrimaryExpression.eval(Unknown Source)
    at bsh.BSHPrimaryExpression.eval(Unknown Source)
    at bsh.BSHVariableDeclarator.eval(Unknown Source)
    at bsh.BSHTypedVariableDeclaration.eval(Unknown Source)
    at bsh.Interpreter.eval(Unknown Source)
    at bsh.Interpreter.eval(Unknown Source)

...
4

1 回答 1

0

您可以尝试使用它来检索 ZK 项目中 WEB-INF 文件夹的完整路径:

Sessions.getCurrent().getWebApp().getRealPath("")+"/WEB-INF/"

希望这对您有所帮助。

于 2017-04-03T12:26:48.773 回答