在谷歌应用程序引擎405中获取此错误此URL不支持HTTP方法GET



Myweb.xml。请在此处检查url模式。是否正确

    <?xml version="1.0" encoding="utf-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
    <servlet>
    <servlet-name>AppEngine</servlet-name>
    <servlet-class>pack.exp.AppEngineServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>AppEngine</servlet-name>
    <url-pattern>/appengine</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    </web-app>

我的jsp文件是这样的。它有一个文本字段和一个按钮。希望将文本字段中提供的数据传递给servlet。然后在新页面上显示数据。

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
       <head>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
            <title>Insert title here</title>
       </head>
       <body>
         <form method="post" action="appengine">
            <fieldset>
             <legend>Text input</legend>
                 <p>
                 <label>Text box</label>
                  <input type="text"  name="myText"/> 
                 </p>
        <button name="submit-action" value="confirm" type="submit">Submit!</button>
          </fieldset>
                </form>
      </body>
    </html>

Servlet文件是这样的。

    package pack.exp;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    @SuppressWarnings("serial")
    public class AppEngineServlet extends HttpServlet 
    {
     @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp)    
         throws 
         ServletException, IOException 
     {
    String output= req.getParameter("myText");
     PrintWriter pw = resp.getWriter();
     pw.println("Hello " + output);
     }
    }

这里提供的代码没有任何问题。必须有一些其他代码库,您必须已上传到应用程序引擎。我获取了你的代码,在本地运行,并将其部署到应用程序引擎云中。一切看起来都很适合你想做的事情。

看看:http://1.testappromin.appspot.com/test.jsp

最新更新