1部署默认访问路径
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>latecoming</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
说明 :
1 <display-name>xxx</display-name>为访问的一级名,这个一定要对应自己的项目名称,如我的项目名为latecoming
2 <welcome-file-list>xxx </welcome-file-list>表示为默认路径列表,及可以有多个<welcome-file>xxx</welcome-file>默认访问路径
3<welcome-file>xxx</welcome-file>为默认访问路径,当浏览器没有指明访问的路径,会使用此默认访问路径,如:
http://localhost:8080/latecoming/ 没有指明访问路径(这里具体到项目名,而没有说明访问项目里的哪一个文件),这是就会使用<welcome-file>xxx</welcome-file>的路径,同时部署多个默认路径时,执行顺序是由上往下,当第一个是有效路径时,访问该路径,否则往下找,只要找到一个有效路径,就使用该路径,如果找完默认路径都没有有效路径,则报错,举个例子:
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>
当用户输入http://localhost:8080/latecoming/ 时,这时服务器会查找<welcome-file>,然后访问login.jsp,是不是存在,不存在就查找下一个index,如果还是不存在,此时已经找完了,服务器就会报一个HTTP Status 404 – Not Found(找不到网页)的错误!