如何从catalina.properties获取值到jsp

How to fetch values from catalina.properties to jsp

本文关键字:jsp 获取 properties catalina      更新时间:2023-09-26

我想把所有值放在catalina.properties中,并希望在jsp中使用它们,而不是使用另一个属性文件。
谁能告诉我该怎么做。

现在我正在使用system.getProperty("variable name","default value")但它不起作用.

你可能想从 servlet 中尝试一下:

InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("/catalina.properties");
Properties properties = new Properties();
properties.load(input);

其余的只是类路径的问题,如果一切正确,您的属性应该加载到属性对象中,您可以在其中检索要查找的数据。那么这只是一个你如何决定把它传递给你的jsp的问题。