复写doGet和doPost的时候总是出现405错误
HTTP method GET is not supported by this URL
不是GET有问题就是POST有问题现在发现其实只是因为复写的时候自带了super.doGet(req, resp);和super.doPost(req, resp);
删掉即可
在外网找到了原因 link:https://stackoverflow.com/questions/20159108/dopost-super-causing-http-status-405
通过看源码应该可以很快找到原因:
HttpServlet.doPost的默认实现返回405错误(不允许使用方法)。 如果要在servlet中支持POST方法,则必须实现doPost方法。
源码: