[英]Where to creating properties file for reading values in a Web application deployed on Weblogic(Linux)
I have a Web application consisting of JSPs, Servlets and Java classes developed in Jdeveloper in Windows. 我有一个Web应用程序,包括在Windows中的Jdeveloper中开发的JSP,Servlet和Java类。
This applicaiton need to be deployed as WAR in Weblogic over a linux box. 此应用程序需要在Linux框中通过Weblogic部署为WAR。 Some of the servlet and Java classes have certain values hardcoded.
某些servlet和Java类具有硬编码的某些值。 I want to avoid this but for obvious reasons.
我想避免这种情况,但原因很明显。 Therfore I was thinking of using the properties file.
因此,我正在考虑使用属性文件。
Now where do i create this properties file in my jdeveloper so that when i create war file of it and and deploy to a Weblogic server, i have access to this Properties file or how should i code it my program so that wherever I put this properties file on my linux like \\u01\\cap\\domain\\machine\\domain_name\\readvalues.properties. 现在我在哪里可以在我的jdeveloper中创建这个属性文件,这样当我创建它的war文件并部署到Weblogic服务器时,我可以访问这个属性文件,或者我应该如何编写我的程序,以便无论我把这个属性放在哪里我的linux上的文件,如\\ u01 \\ cap \\ domain \\ machine \\ domain_name \\ readvalues.properties。 t is able to read it.
t能够阅读它。
and then how do i mention the path in linux. 然后我如何在linux中提到路径。 Can you please help me with the code
你能帮我解释一下代码吗?
Stick the properties file in your war file and access it like you would any other properties file via: 将属性文件粘贴到war文件中,并像访问任何其他属性文件一样访问它:
props.load(MyClass.class.getResourceAsStream("/someProps.properties"));
The best place to put the properties file is in the /WEB-INF/classes folder. 放置属性文件的最佳位置是/ WEB-INF / classes文件夹。 So you need to load the properties files relative to that.
所以你需要加载相对于它的属性文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.