我在$tomcat/webapps/下建了個(gè)myjsp目錄作為我網(wǎng)站的默認(rèn)目錄,在myjsp中有一個(gè)a.jsp文件,該文件要作為我網(wǎng)站的默認(rèn)主頁(yè)。
修改配置文件:
首先,修改$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>標(biāo)簽之間添加上:
<Context path="" docBase="myjsp" debug="0" reloadable="true" />
path是說明虛擬目錄的名字,如果你要只輸入ip地址就顯示主頁(yè),則該鍵值留為空;
docBase是虛擬目錄的路徑,它默認(rèn)的是$tomcat/webapps/ROOT目錄,現(xiàn)在我在webapps目錄下建了一個(gè)myjsp目錄,讓該目錄作為我的默認(rèn)目錄。
debug和reloadable一般都分別設(shè)置成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"改成你的端口
保存上述兩個(gè)文件后重啟tomcat,在瀏覽器地址欄內(nèi)輸入"
http://localhost:8080/
",顯示a.jsp頁(yè)面的內(nèi)容。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
