下面是我的web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>FilterProject</display-name>
<servlet>
<servlet-name>RequestInfoServlet</servlet-name>
<servlet-class>servlets.servlet.RequestInfoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestInfoServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>但我访问http://localhost:8888/login 却提示404错误。
还有,我目前没有加<welcome-file-list>,如果加了之后,再输入上面访问的地址,是先去访问那个servlet呢,还是先访问welcome file里面的index.jsp?谢谢!
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>FilterProject</display-name>
<servlet>
<servlet-name>RequestInfoServlet</servlet-name>
<servlet-class>servlets.servlet.RequestInfoServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestInfoServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>但我访问http://localhost:8888/login 却提示404错误。
还有,我目前没有加<welcome-file-list>,如果加了之后,再输入上面访问的地址,是先去访问那个servlet呢,还是先访问welcome file里面的index.jsp?谢谢!
http://localhost:8888/(这里是你配置的contextPath,如果是root就不可以要。)login
<welcome-file-list>指的是http://localhost:8888/contextPath访问的路径,怎么回去反问你的servlet,除非你配置的servlet的url为*
e.g; http://ip:port/applicationName/login最后,即使楼主你在web.xml中不配置<welcome-file-list>,当你直接这样访问[ http://ip:port/applicationName]时,请求的依然是index.jsp这样页面,除非你对这个请求拦截了,然后重定向到其它的页面上去了
我现在加了context名字,可以访问如下
http://localhost:8888/contextPath/login
但是如果直接访问http://localhost:8888/contextPath (web.xml中没有加welcome file) 却是404错误。
还有,即使我现在加了welcome-file<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>但为什么访问http://localhost:8888/contextPath 也是404错误呢?我现在想访问这个index.jsp,该如何配置呢?(index.jsp在WEB-INF下)
2.无法访问jsp是文件位置错误,与WEB-INF同层就能访问。