問題概述: 借助MyEclipse直接建立了一個Servlet類,每次訪問這個Servlet都能訪問。可自己建立一個Servlet為什么總提示:HTTP Status 405 - HTTP method GET is not supported by this URL。的確是繼承了HttpServlet,而且是重寫了它的doGet()、doPost()方法(注意這兩種方法一定要寫)
public class SearchServlet extends HttpServlet{
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
super.doPost(req, resp);
}
}
解決:問題出來藍色那行代碼,事實上我們是不需要去調用父類的doPost()方法,去掉就可以了!