HTTP Status 405 - HTTP method GET is not supported by this URL
查看源碼可以清晰的看到谢翎,這句話是在HttpServlet中的doGet或者doPost方法中返回的台盯,只要沒有重新這兩個方法嘴高,或者直接通過super.doGet()揣苏、super.doPost()調(diào)用了父類的方法就會出現(xiàn)這個404錯誤健芭。知道原來就容易解決了废睦,解決方法:
在繼承HttpServlet的類中
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doGet(req, resp); ? ? ? ? ? ? ? ? ? ? ? ??//應(yīng)該注釋掉 ?坷虑, 錯誤
PrintWriter out = resp.getWriter();
out.write("this is doGet method");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.doPost(req, resp); ? ? ? ? ? ? ? ? ? ? //應(yīng)該注釋掉 ? 甲馋, 正確
PrintWriter out = resp.getWriter();
out.write("this is doPost method");
}