SpringMVC - RESTful style development

RESTful style development is a URL to locate resources development style. Use develop RESTful URL will become clear, more structured, it is not a standard or protocol;

What is RESTful style?

REST is REpresentational State Transfer abbreviations (generally translated into Chinese Representational State Transfer), REST is an architecture, and HTTP is a REST framework agreement contains the property, in order to facilitate understanding, we call it the first letter of split into different parts:

● representational (REpresentational): REST resources can actually be expressed in a variety of forms, including XML, JSON and even HTML-- most suitable for any form of resource users;
● state (State): When using REST, we are more concerned about the state of the resource rather than the behavior of resources taken;
● Escape (Transfer): REST involve the transfer of resource data, it is transferred in some form of expression from one application to another.

Simply put, REST is the state of the resource to suit the client or server in the form of transfer from the server to the client (or vice versa). In REST, resource identification and location via the URL of , then the behavior (ie HTTP methods) to define how to accomplish REST function.

Examples:

In the usual Web development, common values ​​method is GET and POST, but in fact, HTTP method there are other values ​​PATCH, DELETE, PUT, etc., but these methods often CRUD match the following actions:

CURD action HTTP method
Create POST
Read GET
Update PUT or PATCH
Delete DELETE

Although generally speaking, HTTP methods are mapped to CRUD action, but this is not strictly limited, sometimes PUT can be used to create new resources, POST also be used to update the resource. Indeed, POST request is non-idempotent characteristics (i.e., a URL can be obtained with different results) it into a very flexible method, we can not accommodate other HTTP methods for semantic operations, which are capable.

Before using RESTful style, if we want to add a product data it is usually like this:

/addCategory?name=xxx

But after using a RESTful style will become:

/category

This becomes use the same URL, by convention different HTTP methods to implement different business, that's what did RESTful style, in order to have a more intuitive understanding, cite a map from how2j.cn

 

 

 

@ In: Jane books - @ Author: I do not have three heart  copyright reserved by the authors

Guess you like

Origin www.cnblogs.com/Dm920/p/12152616.html