Problem Analysis:
1, the servlet that inherits from HttpServlet does not rewrite methods such as Doget or dopost, and methods such as Doget or Dopost of the parent class are invoked by default;
2, the parent class HttpServlet doget or Dopost and so on the method overrides you to rewrite Doget or the dopost and so on method;
Whether it is 1 or 2, the default implementation of methods such as the Doget or dopost of the parent class HttpServlet is that an HTTP error that returns a status code of 405 indicates that the request method for the specified resource is not allowed.
Solution:
1, subclasses rewrite Doget or Dopost methods;
2, when you rewrite Doget or dopost in your extended servlert to handle requests and responses, do not invoke the Doget or Dopost methods of the parent class HttpServlet, that is, remove super.doget (request, response) and Super.dopost (request, response);
public class Testservlet extends HttpServlet {
/**
* Serialversionuid:todo (describe what this variable means in one sentence) *
* @since Ver 1.1/
private static final long Serialversionuid = 1L;
@Override
protected void doget (HttpServletRequest req, HttpServletResponse resp)
throws Servletexception, IOException {
printwriter out=resp.getwriter ();
Out.println ("Hello,fucilu");
}
}