zoukankan      html  css  js  c++  java
  • doPost或doGet调用出错(状态代码为405) : HTTP method GET is not supported by this URL

    最近做servlet发现了个问题,解决办法记下来:

     Servlet  eroor:HTTP method GET is not supported by this URL

    错误提示:

     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 (HTTP method GET is not supported by this URL).

    返回状态代码为405HTTP错误表示对于指定资源的请求方法不被允许。

    Servlet 出错:

    Servlet  eroor :HTTP  method  GET  is not  supported  by this UR

    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 ( HTTP   method   GET  is  not   supported  by this  ).

    也有可能是这样的:

    Servlet  eroor :HTTP  method  GET  is not  supported  by this UR

    type: Status report

    message:  HTTP   method   POST  is  not   supported  by this  URL

    description: The specified  HTTP   method  is  not  allowed for the requested resource ( HTTP   method   GET  is  not   supported  by this  ).

    原因是GET或POST不被支持。

    解决方法:

    如果你出错的是HTTP  method  GET  is not  supported  by this ,则用doGet调用doPost.  如:

     1 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     2    throws ServletException, IOException {
     3   doPost(req,resp);
     4  }
     5 
     6 
     7  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
     8    throws ServletException, IOException {
     9   ……
    10 
    11   ……
    12  }

    如果错误是HTTP   method   POST  is  not   supported  by this ,则用doPost调用doGet,如:

     1 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
     2    throws ServletException, IOException {
     3   doPost(req,resp);
     4  }
     5 
     6 
     7  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     8    throws ServletException, IOException {
     9   ……
    10 
    11   ……
    12  }

    OK,解决!

  • 相关阅读:
    Spring-----<context:annotation-config/>
    Spring-----代码中使用注入的Properties配置属性
    Spring-----事务配置的五种方式
    读书汇总贴
    读书_2019年
    有道词典_每日一句_2019/08
    微信小程序 报错Failed to load image
    有道词典_每日一句_2019/07
    微信小程序 base64格式图片的显示及保存
    Mac版微信无法安装之始末
  • 原文地址:https://www.cnblogs.com/yangyi9343/p/4848456.html
Copyright © 2011-2022 走看看