似乎在我的Tapestry应用程序中,我无法从Web-Inf目录或类路径加载INI文件和属性文件。

我尝试了几种不同的方法,应该加载我的文件,但是它们的工作。

  1. Ex

    realm.setResourcePath("/WEB-INF/auth.properties");

    1. Ex

      realm.setResourcePath("classpath:wip/pages/auth.properties");

      我需要加载属性/ ini文件,以便使用基于Shiro的Tapestry-Security模块。

      感谢您的帮助!

有帮助吗?

解决方案

类路径的根部是去的方式。 将您的文件放在 SRC / MAIN / REMUMATION / AUTH.PROPERTIES 中,然后设置您的 Resource路径使用 realm.setresourcepath(“classpath:auth.properties”);

检查扩展程序realmm 和rapestry-security testapp,以了解一个例子

其他提示

try ServletContext.getResourceAsStream("/WEB-INF/auth.properties")ServletContext.getResourceAsStream("WEB-INF/auth.properties")

servletcontext必须从servlet,servletlistener等使用。

尝试

Properties props = new Properties();
props.load(new FileInputStream(new File(req.getServletContext().getRealPath("/WEB-INF/fileName.properties"))));
System.out.println(props);
.

我发现最简单的方法是

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top