使用如下:在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不需要配置。
本文详细介绍了如何在Tomcat的conf/Catalina/localhost目录下为特定项目配置XML文件,包括设置项目的显示名称、基本文档路径等,并展示了如何配置数据库连接资源。
1482

被折叠的 条评论
为什么被折叠?



