我已经为 servlet 编写了这段代码
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Httpservlet1 extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
String color = request.getParameter("color");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<B>The selected color is: ");
pw.println(color);
pw.close();
}
}
我已经编译了它,它对应的 html 文件动作属性值为
action="http://localhost:8765/HS/HTTPSERVLET">
和 web.xml 包含
servlet-name 四个
servlet-class Httpservlet1
xml 代码格式的servlet-name 四个
url-pattern /HTTPSERVLET 仍然在运行时显示错误消息