傳說中的北京呢?
---xingyunpi
jsp web project中,一般情況下,在WEB-INF中可以配置默認的訪問文件名稱,一般情況下是index.html.
遇到的問題:
首先,在TOMCATHOME/conf/server.xml中配置了一個虛擬目錄 admin.sorina ,指向項目中某個文件夾,比如:test(項目名稱)/webmaster/admin/,這個時候,在訪問admin.sorina/的時候,就會訪問admin下的index.html,但是,按照這種思路,我在WEB-INF中配置了一個welcome-file,指定訪問list_1_1.html,但是,用相對路徑訪問,如訪問:admin.sorina/login/的時候,我的目的相當於訪問test(項目名稱)/webmaster/admin/login/list_1_1.html,但是,這個時候卻是出現404錯誤.
解決的辦法:
好像是用這種相對路徑訪問的方式來配置welcome-file是不通的,要在在TOMCATHOME/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>
改爲:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>list_1_1.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
同時在WEB-INF/web.xml中進行對應配置:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>list_1_1.html</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
這樣,就能正常訪問了.