初始文件:
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
connectionTimeout="20000"
redirectPort="8443" />
resourceName="UserDatabase"/>
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
配置后的server.xml:
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false" redirectPort="8443"
acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
URIEncoding="UTF-8"/>
//改端口为80,运行项目时就不需要在网站路径中添加:8080,直接http://localhost/abc就行了。
URIEncoding="UTF-8"设定默认编码方式为UTF-8
URIEncoding="UTF-8"
resourceName="UserDatabase"/>
xmlValidation="false" autoDeploy="true" unpackWARs="true" appBase="webapps" debug="0">
这段代码绑定域名,和设定用域名默认打开的文件,假设项目名称为abc,放在webapps下,然后直接在网页地址栏输入域名:www.baidu.com 就能直接访问项目abc了。如果还有其他项目也放在webapps下,用www.baidu.com/其他项目名称,也可以访问。