struts in the file path problem

Category: Java EE
 
zhongfu2000
2009-11-11 06:44:38

Sponsored Links
I strutsPrj2 project creates a. Properties extension resource files in the src folder, create a class: javaBean.DataBean, the last in this class wrote:

Properties prop = new Properties ();
String path = "configure.properties";
prop.load (new FileInputStream (path));
access mapping my path is:
<Context path = "/ strutsDemo2" ; docBase = "C: \ workspace \ strutsPrj2 \ WebRoot" />

But no matter where I put the file on the server is always able to find the file, please help out and help the younger one, appreciate it.

Sponsored Links

tntlinlxp
2009-11-11 06:53:59
Your path directly to a specific resource file path is not found the?
String strPath = getServlet (). getServletContext (). getRealPath ("/");
get the directory where your project is behind you add specific resources files in your project location should be ok
maimaiti123
2009-11-11 06:56:58
ServletContext context = evt.getServletContext ();
String path = context.getRealPath ("/ ");
dongxiaobin2012
2009-11-11 07:10:56
struts how to determine the root directory of the current program?
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.