In the Tcomcat directory, the default configuration is to place the Web application in the WebApps directory. The default configuration. WebApps is like the root directory of a site. But If the site is a lot. If you put more, you will feel confused. So our situation here is to put the Web application in another place. But also to make the virtual directory of Tomcat.
Here are three ways to do this:
First: (Not recommended):
Change server.xml. Open the file in Notepad. Between <Host> and <context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >
</Context>
Parameter: path represents entering Http://localhost:8080/site in the browser
Docbase represents the physical absolute path of your package, and the default relative path is $tomcat_home$/webapps
Second: (recommended, then and maintenance)
Directly in the $tomcat_home$/conf/catalina/localhost directory to write the configuration file, file name arbitrary, preferably with your Web application is the same easy to manage, such as site.xml content for
<context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >
</Context>
Note: The above use is tomcat5.x,tomcat6.0/conf directory no longer have/catalina/localhost directory, but this method is still feasible, just put the context fragment file into the/conf directory can
Third: Change the entire root directory:
Find Unpackwars= "true" autodeploy= "true" >
Set the appbase to the desired path (absolute path)
Problems occurred: Input: http://localhost:8080/No default page appears
The reason for this is, of course, to change the path. The solution is to copy the document over, or to set the original default to the virtual path.
Configuring the JDBC Connection pool
Directly before us configure the <context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" in the virtual directory >
</Context>
Add the following content
<resource name= "Jdbc/mysqlds" auth= "Container" type= "Javax.sql.DataSource"
Maxactive= "maxidle=" maxwait= "10000"
Username= "Dbusername" password= "Dbpassword" driverclassname= "Com.mysql.jdbc.Driver"
Url= "jdbc:mysql://127.0.0.1:3306/dbname?autoreconnect=true&useunicode=true&characterencoding= gb2312 "/>
The entire configuration becomes as follows:
<context path= "/site" docbase= "C:/site" reloadable= "true" debug= "0" >
<resource name= "Jdbc/mysqlds" auth= "Container" type= "Javax.sql.DataSource"
Maxactive= "maxidle=" maxwait= "10000"
Username= "Dbusername" password= "Dbpasswrod" driverclassname= "Com.mysql.jdbc.Driver"
Url= "jdbc:mysql://127.0.0.1:3306/db?autoreconnect=true&useunicode=true&characterencoding= gb2312 "/>
</Context>
Depending on the actual situation you can change the above italic part.