IT精英网 查看内容

jsp 从web.xml读取连接数据库的参数

2017-9-12 04:43| 发布者: admin| 查看: 7| 评论: 0

摘要: jsp或servlet页面代码:复制代码 代码如下:String driver = application. getIni tParameter ("driver") ; String url = application.getInitParameter("url"); String user = application.getInitParameter ...
jsp或servlet页面代码:

复制代码

代码如下:

String driver = application. getIni tParameter ("driver") ;
String url = application.getInitParameter("url");
String user = application.getInitParameter("user");
String pass = application.getInitParameter("pass");

web.xml需要读取的内容:

复制代码

代码如下:

<context-param>
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost:3306/j2ee</param-value>
</context-param>
<context-param>
<param-name>user</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>pass</param-name>
<param-value>32l47</param-value>
</context-param>

鲜花

握手

雷人

路过

鸡蛋
400-8888-8888
周一至周日 9:00-24:00
意见反馈:postmaster@guaishouxueyuan.net
关于我们

扫一扫关注我们

Powered by Discuz! X3.2© 2001-2013 Comsenz Inc.