A.404错误是因为service方法运行时有错误。
B.405错误有可能是访问时路径拼写有误。
C.500错误有可能是web.xml文件中配置错误。
D.工程没有部署一定会出现404错误。
public class HelloServlet extends HttpServlet{ public HelloServlet() { System.out.println( "HelloServlet的构造器正在执行..."); } public void service(HttpServletRequest request, HttpServletResponse response)//-------------1 throws ServletException,IOException{ System.out.println("service方法正在执行..."); String name = request.getParameter("name"); String rs = "<span style='color:red;font-size:30px;'>" + "hello " + name + "</span>"; response.setContentType("text/html;charset=utf-8"); PrintWriter out = response.getWriter();//------------------------2 out.println(rs);//-----------------------------------------------3 out.close(); } }
本题的详细要求如下: