如何回应(如果可能)在GWT中获取请求? [英] How to respond (if possible) to http get requests in GWT?

查看:86
本文介绍了如何回应(如果可能)在GWT中获取请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的Android手机发出一个http请求(我知道该怎么做)并获取文件作为回报(或服务器上数据库的其他响应)。
是否有可能在服务器端使用GWT(我刚开始阅读教程),或者我将不得不学习PHP或某事。其他?
我见过这个 http://code.google.com /webtoolkit/doc/latest/DevGuideServerCommunication.html ,但不知道这是否是我需要的。



非常感谢!

解决方案

服务器端是一个Servlet引擎,如Jetty或Apache Tomcat(或许多其他)。然后,根据您提供的链接和服务器端Java Servlet(这是GWT希望您提供的内容)编写RPC调用将读取文件并将文件中的数据传输回客户端。然后,应用程序的客户端GWT部分将异步读取消息,然后执行任何操作。

对于Server部分,您需要了解Java,如果您正在编程GWT,我会假设您知道。

如果您想要使用其他内容,例如PHP中的现有HTTP服务,那么您将使用RequestBuilder构建您的获取或发布并将其发送到服务器。

要记住的一件事是,您的客户端文件夹中的所有内容都将由GWT编译为Javascript。所以,即使你在一个项目中工作,你实际上也在编写两个不同的系统。一个在Java中(服务器文件夹)和GWT转换为Javascript的客户端部分,它运行在浏览器中。


I would like to make a http get request with my Android phone (i know how to do that) and get the file in return (or some other response from database on the server). Is it possible to do that in GWT (i just started reading tutorials) on the server side or will i have to learn PHP or sth. else? I've seen this http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html but don't know if this is what i need.

Thank you very much!

解决方案

What you need on the Server side is a Servlet engine such as Jetty or Apache Tomcat (or one of many others). You would then write your RPC call as per the link you provided and the server-side Java Servlet (Which is what GWT expects you to provide) would read the file and transfer the data in the file back to the client. The client GWT part of the app would then read the message asynchronously and then do whatever.

For the Server part you need to know Java, I would assume you know that if you are programming GWT.

If you wanted to use something else, like an existing HTTP service in PHP, then you would use the RequestBuilder to build your get or post and send it to the server.

One thing to remember is that everything in your client folder will be compiled to Javascript by GWT. So even though you are working in one project you are actually coding two different systems. One which is in Java (The server folder) and the client piece which GWT translates to Javascript, which runs in the browser.

这篇关于如何回应(如果可能)在GWT中获取请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆