405: HTTP method GET is not supported by this URL
生活随笔
收集整理的這篇文章主要介紹了
405: HTTP method GET is not supported by this URL
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
【0】README
1)本文旨在解決 ?405: HTTP method GET is not supported by this URL 的問題;
2)本文raw idea is checkouted from ?http://stackoverflow.com/questions/5370633/405-http-method-get-is-not-supported-by-this-url
【1】解決方法:一句話說完,要重寫父類的 doGet 和 doPost方法,就不要調用 super.doGet() 和 super.doPost()方法;如下: public class SampleServlet extends HttpServlet {private static final long serialVersionUID = -5404916983906926869L;/* @Overridepublic void init() throws ServletException {super.init();}*/@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// super.doGet(request, response); // should be commented outresponse.setContentType("text/plain");PrintWriter out = response.getWriter();System.out.println("console info: 請求SampleServlet GET Method");out.println("GET Method: these info are transmitted into client.");out.flush();}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// super.doPost(request, response); // should be commented outresponse.setContentType("text/plain");PrintWriter out = response.getWriter();System.out.println("請求SampleServlet GET Method");out.print("請求SampleServlet POST Method");out.flush();}/*@Overridepublic void destroy() {super.destroy();}*/ }
【1】解決方法:一句話說完,要重寫父類的 doGet 和 doPost方法,就不要調用 super.doGet() 和 super.doPost()方法;如下: public class SampleServlet extends HttpServlet {private static final long serialVersionUID = -5404916983906926869L;/* @Overridepublic void init() throws ServletException {super.init();}*/@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// super.doGet(request, response); // should be commented outresponse.setContentType("text/plain");PrintWriter out = response.getWriter();System.out.println("console info: 請求SampleServlet GET Method");out.println("GET Method: these info are transmitted into client.");out.flush();}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// super.doPost(request, response); // should be commented outresponse.setContentType("text/plain");PrintWriter out = response.getWriter();System.out.println("請求SampleServlet GET Method");out.print("請求SampleServlet POST Method");out.flush();}/*@Overridepublic void destroy() {super.destroy();}*/ }
總結
以上是生活随笔為你收集整理的405: HTTP method GET is not supported by this URL的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑高清励志壁纸1920x1080(好看
- 下一篇: 电脑开vt很卡(电脑开vt变卡)