spring是目前java中最通用的后端架构,它通过loC(控制反转,inversation of Control)的模式。
重要概念
- loC
- POJOs:其实很蠢,意思就是一般java对象,只有简单操作的类,如get和set,entity、bean都是不同的pojo
Rest 接口
GET 是获取数据
PUT 是更新数据
POST是创建数据
- 传入ID后,save方法会执行update,即使没有更新数据,也会返回成功。
DELETE 是删除数据
| HTTP Method | Operation | Definition of Resource URI | What does it do? | Response Status Code | Response Body |
|---|---|---|---|---|---|
| POST | Create | Server generates and returns the URI | Creates a sub-resource (“under” or “within” the passed URI) | 201 CREATED |
The created resource |
| PUT | Create | Client supplies the URI | Creates a resource (at the Request URI) | 201 CREATED |
The created resource |
| PUT | Update | Client supplies the URI | Replaces the resource: The entire record is replaced by the object in the Request | 204 NO CONTENT |
(empty) |
| PATCH | Update | Client supplies the URI | Partial Update: modify only fields included in the request on the existing record | 200 OK |
The updated resource |
Q.E.D.