如何从 GWT 调用 RESTFUL 服务? [英] How to call RESTFUL services from GWT?

查看:25
本文介绍了如何从 GWT 调用 RESTFUL 服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 GWT 作为 Web 开发框架.我需要从我的 GWT 客户端代码访问一些 REST 服务.我还需要解析 JSON(或 XML),这是这些服务的响应格式.解决此问题的最佳方法是什么?

I'm using GWT as web development framework. I need to access some REST services from my GWT client code. Also I need to parse JSON (or maybe XML) which is response format of these services. Which is the best way for this problem?

提前致谢.

推荐答案

您可以使用标准 GWT 调用 REST 服务 RequestBuilder(或 JsonpRequestBuilder(如果您需要调用另一个域上的服务).

You can call REST services using the standard GWT RequestBuilder (or JsonpRequestBuilder if you need to call services on another domain).

有了JSON响应字符串,你可以调用JSONParser.parseStrict(jsonString)得到一个JSONValue,它可以是一个JSONObjectJSONArray 等.这些都可以在 这个包.

With the JSON response string, you can call JSONParser.parseStrict(jsonString) to get a JSONValue, which can be a JSONObject, JSONArray, etc. This is all available in this package.

这篇关于如何从 GWT 调用 RESTFUL 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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