代码如下:
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-namedriver/param-name
param-valuecom.mysql.jdbc.Driver/param-value
/context-param
context-param
param-nameurl/param-name
param-valuejdbc:mysql://localhost:3306/j2ee/param-value
/context-param
context-param
param-nameuser/param-name
param-valueroot/param-value
/context-param
context-param
param-namepass/param-name
param-value32l47/param-value
/context-param
猜你喜欢