使用 RESTful Web 服务进行 Ajax 的好处?

发布于 2024-12-23 05:50:34 字数 234 浏览 2 评论 0原文

如果我错了,请纠正我,但似乎很多人都在使用 RESTful Web 服务向 Ajax 提供数据。然而,普通的 Servlet 或 PHP 页面可以轻松地向 Ajax 应用程序提供该信息。因此,我没有看到创建 Web 服务(即使是 RESTful 服务)为 Ajax 调用提供数据的好处。

所以,我的问题是:使用 RESTful Web 服务(而不是使用简单的 Servlet 或 PHP 页面)来为 Ajax 应用程序提供响应有什么好处?

Correct me if I'm wrong, but it seems that many people are using RESTful web services to provide data to Ajax. However, a normal Servlet or PHP page can easily provide that information to Ajax applications. So, I don't see the benefit of creating web service, even a RESTful one, to provide data to Ajax calls.

So, my question is: what is the benefit of using a RESTful web service, rather than using a simple Servlet or PHP page to provide response to a Ajax application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

当爱已成负担 2024-12-30 05:50:34

RESTful Web 服务 使用 HTTP 协议和 HTTP 方法进行调用。 RESTful Web 服务没有任何像“大”(SOAP) Web 服务那样的特殊协议。

因此,Servlet 也可用于创建 RESTful Web 服务。事实上,如果您使用 doGet(-) 方法创建一个简单的 Servlet,您就创建了一个为 GET HTTP 方法调用提供服务的 RESTful Web 服务。
简单的 PHP 页面也是如此。

如果您将 RESTful Web 服务称为即 JAX-RS 实现,那么它会为您带来灵活性和易于开发性(@Produces@Consumes@FormParam,多个@GET方法等)

RESTful Web Services are using the HTTP protocol and HTTP Methods for invocation. RESTful Web Services doesn't have any special protocol like "big" (SOAP) Web Services have.

Therefore, Servlets can be used to create RESTful Web Services as well. In the matter of fact, if you create a simple Servlet with doGet(-) method, you've just created a RESTful Web Service serving GET HTTP Method invocations.
The same is with your simple PHP page.

If you're referring to RESTful Web Services as an i.e. JAX-RS implementation, than it buys you a flexibility and ease of development (@Produces, @Consumes, @FormParam, multiple @GET methods etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文