web.xml 配置了 dispatchServelt ,为什么还走到index.jsp

时间:2022-09-22 23:29:44

webapp 下有index.jsp .

项目里 web.xml  中没有 welcomelist

项目上下文  /

dispatchservlet 拦截的url 为 /



但是  tomcat 服务器启动以后,

访问  根目录  总是找到webapp 下的index.jsp

为什么呢?


因为tomcat服务器conf 目录下也有一个web.xml  ,里面也配置有welcomelist

 tomcat 发现访问根目录时候,会判断根目录下是否有index.jsp 

如果有就直接访问 index.jsp.这时候还没有走到dispatcheServlet .


如果 没有index.jsp ,则会走到dispatchservlet.

所以解决办法两个:

1 是 index.jsp 改名字。

2 删除项目和服务器里web.xml 中的 welcomelist.