Properties pro = new Properties()
pro.load(new FileInputStream((c:/哗拦梁jdbc.properties")))//配置文件路径
db_userName = pro.getProperty("db_userName")
db_passWord = pro.getProperty("db_passWord"乱运衡则)
%>
之后自己用eclipse或者IDEA加try catch
可以.java提供闹毁扒了java.uitl.Properities这个类去调用这类文件的。Properties p = new Properties()
p.load(ZCloudServiceImpl.class.getResourceAsStream("/config/config.properties"))
OutputStream fos = new FileOutputStream(A.class.getResource("/config/config.properties").getPath())
p.setProperty("zCloud.primaryNode"液昌, value)
p.store(fos, ""余如)
java里可以再在resources里面新建一个XML file或者 file文件XML file 会自衡贺动生成XML头,在下面加入高掘内容就可以了,首先要有一个根节点,然后如果需要用到一些类咐念派,如:spring的一些类,就需要引入包,如:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.dist.*.controller" />
</beans >
其中<?xml ……就是头,<beans 是根节点,下面的<content:……是内容。
如果添加的事properties文件,格式如下:
# 连接池配置
pool.size = 2
pool.max = 50
然后jsp调用读取xml文件的方法去读取自重的内容就可以了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)