我试图使用谷歌应用引擎在java上使用网络应用。我有一个发送http-post请求的应用程序。
答案 0 :(得分:2)
创建一个处理POST的servlet on GAE:
public class ExampleAppServlet extends HttpServlet{
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
// get some data from POST
InputStream input = req.getInputStream();
// do something with input
// send back some reply
resp.getWriter().write("Hello Example App").close();
}
}
将此servlet映射到web.xml
config file中的URL:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<servlet>
<servlet-name>example_app_servlet</servlet-name>
<servlet-class>com.package.ExampleAppServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>example_app_servlet</servlet-name>
<url-pattern>/example_app</url-pattern>
</servlet-mapping>
</web-app>