如何设置 web 项目打开的默认页面
引言
我們?cè)趧?chuàng)建 Web 項(xiàng)目啟動(dòng) Tomcat 會(huì)自動(dòng)打開(kāi)一個(gè)默認(rèn) index.jsp 頁(yè)面,這個(gè)頁(yè)面是創(chuàng)建 Web 項(xiàng)目時(shí)就自動(dòng)生成的。那么,如何設(shè)置 web 項(xiàng)目打開(kāi)的這個(gè)的默認(rèn)頁(yè)面,改為自己的默認(rèn)啟動(dòng)頁(yè)面呢?
修改配置 web.xml 文件
在 web.xml 配置文件設(shè)置默認(rèn)頁(yè)面
<welcome-file-list>
<welcome-file>login.html</welcome-file>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
在 tomcat 啟動(dòng)項(xiàng)目時(shí),就會(huì)在項(xiàng)目目錄下面自上而下逐一查找文件,如果找到了如上 6 個(gè)中的某一個(gè)文件,則以這個(gè)文件為 welcom-file,也就是這個(gè)項(xiàng)目的默認(rèn)頁(yè)面。
如果我們只需要一個(gè)打開(kāi)默認(rèn)頁(yè)面,那么就只配置一個(gè)即可,如下:
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
這時(shí),就可以把項(xiàng)目中自動(dòng)生成的 index.jsp 頁(yè)面刪除了。
作者:Binge
出處:http://www.cnblogs.com/binbingg/
本文版權(quán)歸作者和博客園共有,轉(zhuǎn)載必須給出原文鏈接,并保留此段聲明,否則保留追究法律責(zé)任的權(quán)利。
總結(jié)
以上是生活随笔為你收集整理的如何设置 web 项目打开的默认页面的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。