从ZUL ZK 3.6中的webinf文件夹中获取路径文件

时间:2017-03-31 10:40:45

标签: java zk zul

我如何从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)

...

1 个答案:

答案 0 :(得分:0)

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

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

希望这会对你有所帮助。