Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
应用程序引擎简单java Web服务_Java_Web Services_Google App Engine - Fatal编程技术网

应用程序引擎简单java Web服务

应用程序引擎简单java Web服务,java,web-services,google-app-engine,Java,Web Services,Google App Engine,我喜欢将一个JAVA方法公开为一个Web服务,它将接受POST,去掉其中的参数并相应地回复。我读到我必须使用doPost(req,resp),但是我如何获得servlet代码?web.xml中应该包含什么?不会有欢迎文件吗?映射servlet后,我是否可以在不需要将index.html作为起点的情况下读取它?在servlet中创建doPost(req,resp)方法,并将其映射到web.xml <servlet> <servlet-name>HelloPo

我喜欢将一个JAVA方法公开为一个Web服务,它将接受
POST
,去掉其中的参数并相应地回复。我读到我必须使用
doPost(req,resp)
,但是我如何获得servlet代码?
web.xml
中应该包含什么?不会有欢迎文件吗?映射servlet后,我是否可以在不需要将
index.html
作为起点的情况下读取它?

在servlet中创建
doPost(req,resp)
方法,并将其映射到
web.xml

<servlet>
        <servlet-name>HelloPost</servlet-name>
        <servlet-class>packageName.HelloPost</servlet-class>
</servlet>

<servlet-mapping>
        <servlet-name>HelloPost</servlet-name>
        <url-pattern>/post-url</url-pattern>
</servlet-mapping>

如果您想知道如何将
web.xml
设置为启动servlet,那么您可以从这里开始

<welcome-file-list>
        <welcome-file>/post-url</welcome-file>
</welcome-file-list>