[英]Getiing this error in google app engine 405 HTTP method GET is not supported by this URL
My web.xml. 我的web.xml。 Please check the url-pattern here.
请在此处检查url模式。 is it correct or not
是否正确
<?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>
My jsp file is like this. 我的jsp文件是这样的。 It has a textfield and a button.
它具有一个文本字段和一个按钮。 want to pass the data provided in the text field to the servlet.
想要将文本字段中提供的数据传递给servlet。 and then displays the data on new page.
然后在新页面上显示数据。
<%@ 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 file goes like this. 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);
}
}
There is nothing wrong with the code that you have presented here. 您在此处提供的代码没有错。 There must be some other code base that you must have uploaded to the App Engine.
您必须已将其他代码库上传到App Engine。 I took your code, ran it locally and deployed to the App Engine cloud too.
我获取了您的代码,在本地运行并也部署到了App Engine云中。 Everything looks good for what you want to do.
一切看起来都很适合您想做的事。
Take a look : http://1.testappromin.appspot.com/test.jsp 看看: http : //1.testappromin.appspot.com/test.jsp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.