在不使用Jersey或任何其他库的情况下创建RESTful WebService [英] Creating a RESTful WebService without using Jersey or any other libs

查看:103
本文介绍了在不使用Jersey或任何其他库的情况下创建RESTful WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,您可能会说它是

okay you might say its a duplicate of this.

可能是,但是答案仍未找到.

It might be but the answer is still yet to be found.

在没有使用jersey或其他任何库的情况下,有没有什么方法可以使我们成为RESTful Web服务?

Isn't there any way we can make a RESTful web service without using jersey or for that matter any other libs?

我正在搜索过去5天的问题的答案!

I am searching for the past 5 days for the answer to this question!!

推荐答案

您应该能够使用servlet来完成此任务. 为您公开给服务使用者的每个服务或URL创建一个servlet.

You should be able to accomplish this with servlets. Create a servlet for each service or url that you expose to your service consumers.

例如.对于用户CRUD服务,创建一个UserServlet并将映射指定为/user/*. 您的服务的使用者将点击

Eg. For a user CRUD service, create a UserServlet and specify the mapping as /user/*. Consumers of your service, will hit urls such as

  • http://yourdomain.com/user
  • http://yourdomain.com/user/23

用于各种RESTful操作.

for various RESTful operations.

在servlet内部,您应该能够提取请求参数,表单数据,请求标头和上下文信息.

Inside of the servlet, you should be able to extract the request parameters, form data, request headers and context information.

有关如何设计Restful API和最佳实践的详细讨论,请搜索"Restful API Design".这里有几个链接可以帮助您入门

For a detailed discussion on how to design your restful api and best practices, search "Restful API Design". Here are a couple of links to get you started

  • https://blog.apigee.com/detail/api_design_third_edition_video_slides
  • https://blog.apigee.com/detail/slides_for_restful_api_design_second_edition_webinar/

这篇关于在不使用Jersey或任何其他库的情况下创建RESTful WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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