首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

如何样读取tomcat 上的properties文件

2012-09-19 
怎么样读取tomcat 下的properties文件怎么样读取C:\Program Files (x86)\Apache Software Foundation\Tomc

怎么样读取tomcat 下的properties文件
怎么样读取C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps\test\WEB-INF\classes下的db.properties文件 求大侠指教 谢谢

[解决办法]
lz是用jsp吗?如下

Java code
<%@page import="java.io.InputStream" %><%@page import="java.util.Properties" %><%    InputStream is= application.getResourceAsStream("/db.properties");    Properties props = new Properties();    props.load(is);%>
[解决办法]
lz是用jsp吗?如下

Java code
<%@page import="java.io.InputStream" %><%@page import="java.util.Properties" %><%    InputStream is= application.getResourceAsStream("/db.properties");    Properties props = new Properties();    props.load(is);%>
[解决办法]
InputStream in = new FileInputStream(path);
Properties property = new Properties();
property.load(in);
ResourceBundle bundle = ResourceBundle.getBundle("db");
String driverClassName = bundle.getString("driverClassName");
[解决办法]
InputStream in = new FileInputStream(path);
Properties property = new Properties();
property.load(in);
ResourceBundle bundle = ResourceBundle.getBundle("db");
String userName = bundle.getString("userName");

热点排行