简体   繁体   English

app引擎简单的java webservice

[英]app engine simple java webservice

I like to expose one JAVA method as a Web service that will accept POST ,strip the parameters out of it and reply accordingly. 我喜欢将一个JAVA方法暴露为接受POSTWeb服务 ,从中删除参数并相应地进行回复。 I read I have to use doPost(req,resp) , but How can I get to the servlet code? 我读过我必须使用doPost(req,resp) ,但是如何才能获得servlet代码? what should be in web.xml ? 什么应该在web.xml there will not be a welcome-file ? 不会有欢迎档案? After mapping the servlet, can I read it without the need for a index.html as start point? 在映射servlet之后,我是否可以在不需要index.html作为起点的情况下阅读它?

create the doPost(req,resp) method in your servlet and map it to a url in web.xml 在servlet中创建doPost(req,resp)方法,并将其映射到web.xml的url

<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>

then you can post your request to /post-url .You don't need to use index.html.Any url can be put in welcome file to load for the url / To set /post-url as landing page , use 然后你可以将你的请求发布到/post-url 。你不需要使用index.html.Any url可以放在欢迎文件中加载url /设置/post-url作为登陆页面,使用

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

you can get started here https://developers.google.com/appengine/docs/java/gettingstarted/creating 你可以在这里开始https://developers.google.com/appengine/docs/java/gettingstarted/creating

如果您想知道如何设置web.xml以启动servlet,那么可能会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM