HTTP Status 405 - HTTP method POST is not supported by this URL

前端 未结 2 1466
终归单人心
终归单人心 2021-01-03 08:06

I am getting the error HTTP Status 405 - HTTP method POST is not supported by this URL when I use the following code(below) ... the line causing the trouble (ap

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 08:56

    (sorry about the wrong answer I posted before, I deleted it).


    Apparently the URL /EditObject is mapped on another servlet which doesn't have doPost() method overriden. It would be called on RequestDispatcher#forward() as well because the method of currently running HTTP request is POST. The default HttpServlet#doPost() implementation will return HTTP 405. If your actual intent is to fire a GET request on it so that the doGet() method will be invoked, then you should rather use HttpServletResponse#sendRedirect() instead.

    response.sendRedirect("/EditObject?id="+objId);
    

提交回复
热议问题