Spring MVC's RESTful API

Source: Internet
Author: User
Tags representational state transfer

Spring MVC's RESTful API

这是一个路径,http://127.0.0.1:8080/OperationAPI/v0.1/pins/3是API的具体网址。在RESTful架构中,每个网址代表一种资源(resource),所以网址中不能有动词,只能有名词,而且所用的名词往往与数据库的表格名对应。一般来说,数据库中的表都是同种记录的"集合"(collection),所以API中的名词也应该使用复数。http://127.0.0.1:8080表示的本地的域名,OperationAPI表示的是项目名称,v0.1表示的api的版本号,pins表示这个api提供数据库中pins表的具体信息。3表示pins表中对应的某个列的id,这里是个pin_id。

1,api the communication protocol with the user, always using the HTTPS protocol.

2, you should try to deploy the API under a dedicated domain name, such as OPERATIONAPI This API is deployed under the local domain name.

3, the API version number should be placed in the URL, such as v0.1

4, for the specific operation type of the resource, is represented by the HTTP verb.

The usual HTTP verbs have the following four (the corresponding SQL command in parentheses).

          GET(SELECT):从服务器取出资源。          POST(CREATE):在服务器新建一个资源。          PUT(UPDATE):在服务器更新资源。          DELETE(DELETE):从服务器删除资源。

Here are some examples:

    • Post/pin: Create a new PIN.
    • GET/PINS/3: Gets the information for the specified pin_id of 3.
    • PUT/PINS/3: Updates the information for the specified pin_id to 3.
    • DELETE/PINS/3: Deletes the specified information for pin_id 3.
      The resources distributed around are determined by the URL, and REST is a client-side app that uses URLs to get a representation of the resource. Obtaining these representations causes these applications to transform their state. As the representation of resources is constantly being obtained, the client application is constantly changing its state, which is called Representational State transfer (representational Transfer). Popular point is that you have a Web page to get resources, such as getting a database of data, you have to call Restapi to get, this API action is get, your state becomes get this state, you want to delete a resource in the database, Delete is called by calling Delete, and your state becomes a delete restapi.

Spring MVC's RESTful API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.