Google app engine 此URL不支持HTTP方法GET-谷歌应用程序引擎 公共类MailHandlerServlet扩展了HttpServlet{ @凌驾 public void doPost(HttpServletRequest-req、HttpServletResponse-resp) 抛出ServletException、IOException{ 试一试{ Properties props=新属性(); 会话session1=Session.getDefaultInstance(props,null); MimeMessage message=新的MimeMessage(session1,req.getInputStream()); //从Mime消息中提取重要字段 字符串subject=message.getSubject(); 字符串contentType=message.getContentType(); 打印部件(消息); //解析出多部分 //基于电子邮件执行业务逻辑 } 捕获(IOException | MessaginException ex){ } } 私有静态void打印部件(Part p)引发IOException、MessaginException{ 对象o=p.getContent(); 如果(字符串的o实例){ println(“这是一个字符串”); out.println((字符串)o); } else if(多部分的o实例){ out.println(“这是一个多部分”); 多部分mp=(多部分)o; int count=mp.getCount(); for(int i=0;i

Google app engine 此URL不支持HTTP方法GET-谷歌应用程序引擎 公共类MailHandlerServlet扩展了HttpServlet{ @凌驾 public void doPost(HttpServletRequest-req、HttpServletResponse-resp) 抛出ServletException、IOException{ 试一试{ Properties props=新属性(); 会话session1=Session.getDefaultInstance(props,null); MimeMessage message=新的MimeMessage(session1,req.getInputStream()); //从Mime消息中提取重要字段 字符串subject=message.getSubject(); 字符串contentType=message.getContentType(); 打印部件(消息); //解析出多部分 //基于电子邮件执行业务逻辑 } 捕获(IOException | MessaginException ex){ } } 私有静态void打印部件(Part p)引发IOException、MessaginException{ 对象o=p.getContent(); 如果(字符串的o实例){ println(“这是一个字符串”); out.println((字符串)o); } else if(多部分的o实例){ out.println(“这是一个多部分”); 多部分mp=(多部分)o; int count=mp.getCount(); for(int i=0;i,google-app-engine,servlets,cloud,Google App Engine,Servlets,Cloud,上面的代码给了我一个类似这样的错误…“此URL不支持HTTP方法GET”请帮助我修复它。我正在GAE中部署它。我编写此代码是为了接收发送到我的appspot.com的邮件。我还更新了appengine-web.xml和web.xml。当我尝试运行页面时,它会显示此错误 此servlet中没有doGet方法,您正在对其进行GET调用。您要么进行POST调用,要么实现GET方法。例如: public class MailHandlerServlet extends HttpServlet {

上面的代码给了我一个类似这样的错误…“此URL不支持HTTP方法GET”请帮助我修复它。我正在GAE中部署它。我编写此代码是为了接收发送到我的appspot.com的邮件。我还更新了appengine-web.xml和web.xml。当我尝试运行页面时,它会显示此错误

此servlet中没有
doGet
方法,您正在对其进行GET调用。您要么进行POST调用,要么实现GET方法。例如:

   public class MailHandlerServlet extends HttpServlet { 
    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {

    try {

    Properties props = new Properties();
    Session session1 = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session1, req.getInputStream());

     //Extract out the important fields from the Mime Message
     String subject = message.getSubject();    
    String contentType = message.getContentType();

    printParts(message);
    //Parse out the Multiparts
    //Perform business logic based on the email
    }
    catch (IOException | MessagingException ex) {

     }
    }

    private static void printParts(Part p) throws IOException, MessagingException {
    Object o = p.getContent();

    if (o instanceof String) {
        out.println("This is a String");
    out.println((String)o);
    }
    else if (o instanceof Multipart) {
    out.println("This is a Multipart");
    Multipart mp = (Multipart)o;

    int count = mp.getCount();
    for (int i = 0; i < count; i++) {
    printParts(mp.getBodyPart(i));
    }
    }
    else if (o instanceof InputStream) {
    out.println("This is just an input stream");
    InputStream is = (InputStream)o;
    int c;
    while ((c = is.read()) != -1)
    out.write(c);
    }
    }

    }

最近,我还在开发名为DrEdit的google应用程序引擎示例web应用程序,我也遇到了这个错误。我编写了以下代码使其工作

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    doPost(request, response);
}

您需要为应用程序编写类似的doGet方法。希望有帮助

您已经实现了
doPost
,它用于POST请求。对于GET请求,您需要
doGet
methodOK!!收到了!我已将其更改为doPost,现在错误是“错误:此URL不支持HTTP方法POST”如何排除此问题?您应该同时拥有
doPost
doGet
方法-如果需要,其中一个方法可以为空。如果在那之后仍然出现此错误消息,则意味着您调用了错误的servlet。
@Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
      System.out.println("start of GoogleDriveAuth:::::::");
      credentialManager = new CredentialManager(
                getClientSecrets(), TRANSPORT, JSON_FACTORY);
      handleCallbackIfRequired(req, resp);