[英]can jsp access .jar files?
I have a properties file in JAR
file. 我在
JAR
文件中有一个属性文件。
In my web application, I want to access this properties file from the jsp
within web application. 在我的Web应用程序中,我想从Web应用程序中的
jsp
访问此属性文件。
I try doing it with the following code, but results in FileNotFoundException
我尝试使用以下代码,但导致
FileNotFoundException
Properties properties = new Properties();
properties.load(new FileInputStream("myfile.properties"));
How can i access the file from JAR
which is in my classpath
within scriptlets
in jsp? 如何从jsp中的
scriptlets
中的classpath
JAR
访问该文件?
Thanks in advance. 提前致谢。
Yes you can using 是的,你可以使用
InputStream in = this.getClass().getClassLoader().getResourceAsStream("//myfile.properties");
Make sure your jar file which has this property file is in classpath. 确保具有此属性文件的jar文件位于类路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.