问题描述 :
WEB+Servlet+Tomcat项目 , 访问Servlet时报错
问题信息 :
HTTP Status 405
type
: Status report
message
: HTTP method GET is not supported by this URL
description
: The specified HTTP method is not allowed for the requested resource.
原因
归根究底都是调用了HttpServlet的doXXX()方法 :
1. 继承HttpServlet的Servlet未重写覆盖所需调用的方法:doGet(),doPost()等方法;
2. 重写的方法中调用了super.doXXX(),导致Servlet的方法未被调用,而是调用的父类HttpServlet的默认方法
解决方法
1. 检测Servlet中是否重写了被调用的方法
2. 检测目标方法中是否调用了super.doXXX()