亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

配置TOMCAT 修改默認ROOT路徑

系統 1808 0

本文轉載 http://xxs673076773.iteye.com/blog/1134805

最合適的)
最直接的辦法是,刪掉tomcat下原有Root文件夾,將自己的項目更名為Root。

我在$tomcat/webapps/下建了個myjsp目錄作為我網站的默認目錄,在myjsp中有一個a.jsp文件,該文件要作為我網站的默認主頁。

修改配置文件:

首先,修改$tomcat/conf/server.xml文件。
在server.xml文件中,有一段如下:
……
<engine name="Catalina" defaultHost="localhost">
<host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
……
<host>
</engine>
……
在<host></host>標簽之間添加上:

<Context path="" docBase="myjsp" debug="0" reloadable="true" />

path是說明虛擬目錄的名字,如果你要只輸入ip地址就顯示主頁,則該鍵值留為空;

docBase是虛擬目錄的路徑,它默認的是$tomcat/webapps/ROOT目錄,現在我在webapps目錄下建了一個myjsp目錄,讓該目錄作為我的默認目錄。

debug和reloadable一般都分別設置成0和true。

然后,修改$tomcat/conf/web.xml文件。
在web.xml文件中,有一段如下:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
在<welcome-file-list>與<welcome-file>index.html</welcome-file>之間添加上:

<welcome-file>a.jsp</welcome-file>

更改端口
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />?


將port "8080"改成你的端口

保存上述兩個文件后重啟tomcat,在瀏覽器地址欄內輸入" http://localhost:8080/ ",顯示a.jsp頁面的內容。
(一)
【轉】?如何修改TOMCAT的默認主頁為你自己項目的主頁
啟動tomcat之后,在貓頁上有這么一段話:
As you may have guessed by now, this is the default Tomcat home page. It can be found on the local filesystem at:?
$CATALINA_HOME/webapps/ROOT/index.html
這就說明,無論你怎么折騰你自己的web.xml文件,對不起,tomcat只認它自己的web.xml定義的welcome頁面。
而<welcome-file-list>標簽上的這段注釋:
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure that you include any of the default values that -->
<!-- you wish to include.
-->
修改過程
1.不要碰conf目錄下的那個web.xml文件,讓它老死在那里吧。
2.把原來的ROOT目錄清空,里面什么都不要留。刪掉或者改名隨便你怎么弄都成。只要清空就好。
3.發布你自己的項目到ROOT目錄下,用war包發布或者用直接拷貝的都一個效果。保證index.html/index.htm/index.jsp其中一個存在于ROOT目錄下。
4.刪除%CATALINA%/work目錄下的一切。我就是沒有清理這個目錄,導致 http://localhost:8080 永遠都是那只貓~~~~郁悶
5.通知服務商重啟tomcat。
(二)

這里把用指定項目的主頁替換tomcat主頁的方法記錄一下:

1、? 更改 tomcat 端口為 80

在tomcat目錄conf下找到server.xml打開,找到

<Connector? port="80" ?protocol="HTTP/1.1"

connectionTimeout="0"

redirectPort="8443" URIEncoding="gb2312"/>

port改為80.

如端口80被占用,解決方法:解決:在win的cmd命令窗口輸入netstat -abn ->c:/port80.txt?然后到c盤port80.txt文件中找到占用80端口的程序pid,記下pid。打開任務管理器,點擊“查看”/選擇列,勾選“PID(進程標識符)”,然后單擊“進程”標簽,找到80端口對應的pid,就可以看到是那個程序占用的了,更改這個程序的port,再重啟這個程序,使更改生效。

2、? 設置默認訪問主頁為指定項目。

在server.xml中找到

<Host name="localhost"?appBase="webapps"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

</Host>

在標簽中間插入:

<Context path=""?docBase="xbwl"?debug="0" reloadable="true"/>

docBase="xbwl" xbwl即為指定的項目。

完整如下:

<Host name="localhost"?appBase="webapps"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">

<Context path=""?docBase="xbwl"?debug="0" reloadable="true"/>

</Host>

?

(三)

可以通過以下操作實現更改tomcat的默認主頁所在的目錄。
替換并保存一下內容為conf文件夾下的server.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
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" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",?
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"?
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="80
connectionTimeout="20000"?
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"?
connectionTimeout="20000"?
redirectPort="8443" />
-->?
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the?
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">?
-->?
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->?

<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->

<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Context path="" docBase="C:\Tomcat6\webapps\pms" workDir="C:\Tomcat6\webapps\pms"/>?

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"?
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->

</Host>
</Engine>
</Service>
</Server>

(四)

方法一:(適合對服務器中單個站點的設置)
(d:\demo\為站點根目錄)
在Tomcat中,默認主頁為:index.html,index.htm,index.jsp
如果需要使用其他頁面作為默認主頁,需要配置WEB-INF文件夾下的web.xml文件:
如上例中:
在D:\demo\WEB-INF\文件夾中建立文件web.xml:
內容如下:


<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”2.4″
xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd “>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>

方法二:(以下設置將應用于該服務器下所有的站點)推薦使用
打開文件conf/web.xml,找到這段代碼:

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

在中間加入你想要的文件名即可。
如:我想讓hello.jsp成為默認首頁,我將上面那段代碼改成:

<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

配置TOMCAT 修改默認ROOT路徑


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!??!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩你懂得 | 亚洲91| 国产成人一区二区三中文 | 九九啪 | 欧美一级毛片在线播放 | sihu永久在线播放地址 | 四虎永久免费网站入口2020 | 五月婷婷亚洲综合 | 性久久| 高清在线精品一区二区 | 国产一区二区久久 | 狠狠色丁香婷婷综合视频 | 操一操日一日 | 久久精品伊人波多野结 | 色老头福影院韩国激情影院 | 国产一区二区精品久久岳 | 久久影视在线观看 | 国产成人综合95精品视频免费 | 亚洲精品丝袜在线一区波多野结衣 | 精品理论片一区二区三区 | 狠狠干人人插 | 国产一级一级毛片 | 精品一区二区三区色花堂 | 成人99国产精品一级毛片 | 四虎影院免费观看视频 | 日韩区欧美区 | 日韩中文字幕视频在线 | 青青青国产免费全部免费观看 | 精品一区二区三区免费视频 | 亚洲在线国产 | 国内精品一区视频在线播放 | 日本韩国欧美在线 | 精品国产一区二区三区不卡在线 | 久久www免费人成_看片高清 | 九九国产视频 | 日韩午夜免费视频 | 色拍拍噜噜噜aⅴ在线观看 色拍拍欧美视频在线看 | 亚洲成人av | 在线观看精品国产 | 国产毛片久久久久久国产毛片 | 久久天堂成人影院 |