使用如下:在conf/Catalina/localhost下新增与项目同名的配置文件
bbs.xml
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="web" docBase="E:/work/bbstest/WebRoot" path="/bbs" workDir="E:/work/bbstest/WebRoot">
<Resource name="jdbc/bbs" type="javax.sql.DataSource" password="root" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/bbs?autoReconnect=true&useUnicode=true&characterEncoding=GB2312" maxActive="100"/>
</Context>
testdb.xml
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="testdb" docBase="E:/vmware/apache-tomcat-5.5.29/testdb" path="/testdb" workDir="E:/vmware/apache-tomcat-5.5.29/testdb">
<Resource name="jdbc/E5NEW" type="javax.sql.DataSource" password="root" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/testdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8" maxActive="100"/>
</Context>
只要配置这个即可。web.xml不需要配置。