标签:
安装tomcat以后可以直接使用web来进行管理
1.Web管理:
进入http://localhost:8080/进入管理页面,点击“Host Manager”,会提示用户名和密码
在tomcat安装目录\conf\tomcat-users.xml 进行用户配置,并将用户分配给页面”页面提示的组“
<role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="你的用户名" password="你的密码" roles="admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status"/>
2.配置虚拟目录并启动
在Web管理页面进入"Manager App"页面,在"Deploy"中
Context Path (required): 这里必须已/开头,然后是虚拟目录的名字
XML Configuration file URL: 未知
WAR or Directory URL: JSP程序打包的WAR文件或JSP程序所在的目录地址
如果提示程序启动错误,进入到tomcat安装目录\conf,打开catalina.properties文件,将(避免tomcat7扫描每个虚拟目录下WEB-INF\lib)
tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ 改为 tomcat.util.scan.DefaultJarScanner.jarsToSkip=\,*
3.配置Web程序的数据库连接
i)在Web程序的 WEB-INF\web.xml 文件中添加
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app id="StrutsWuApplication"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <resource-ref> <description>Database connection</description> <res-ref-name>jdbc/你的配置名</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app>
ii)配置对应的信息(任一文件中)
在Web程序的 META-INF\context.xml
在tomcat安装目录\conf\context.xml
在tomcat安装目录\conf\Catalina\localhost\虚拟目录名.xml
在tomcat安装目录\conf\server.xml
MySql <Resource name="jdbc/你的配置名" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" username="数据库连接用户名" password="数据库连接密码" url="jdbc:mysql://localhost:3306/数据库名" maxIdle="20" maxWait="5000" /> MsSql <Resource name="jdbc/你的配置名" auth="Container" type="javax.sql.DataSource" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver" username="数据库连接用户名" password="数据库连接密码" url="jdbc:microsoft:sqlserver://localhost:1433;databasename=数据库名" maxActive="8" maxIdle="4"/>
标签:
原文地址:http://www.cnblogs.com/gameshan/p/4656834.html