【发布时间】:2017-12-23 17:40:59
【问题描述】:
我在浏览器的地址栏中输入 localhost:8080/projectName/Myservlet,得到 404 错误。
Myservlet.java
package com.test.servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Myservlet extends HttpServlet{
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException{
PrintWriter out=response.getWriter();
out.println("<html><body><h1>Today</h1>Myservlet</body></html>");
}
}
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" 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">
<Servlet>
<Servlet-name>servlet</Servlet-name>
<Servlet-class>Myservlet</Servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-name>servlet</Servlet-name>
<url-pattern>/Myservlet</url-pattern>
</Servlet-mapping>
</web-app>
【问题讨论】:
-
如果您之前设置了本地服务器,您可能在端口 8081 上运行。确保您验证了这一点——但对于 GP,它是什么类型的服务器?你在用球衣吗?给我们更多信息
标签: jsp servlets http-status-code-404