跳至主要内容

博文

目前显示的是标签为“Spring mvc”的博文

Building REST APIs with Spring MVC

As stated in before posts, we are going to build a Blog system. To demonstrate REST API, we use a simple Post entity to persist blog entries, and expose the CRUD operations via REST APIs to client applications. As a REST API consumer, the client applications could be a website, a desktop application, or a mobile application. Following the REST API convention and HTTP protocol specification, the post APIs can be designed as the following table. Uri Http Method Request Response Description /posts GET 200, [{'id':1, 'title'},{}] Get all posts /posts POST {'title':'test title','content':'test content'} 201 Create a new post /posts/{id} GET 200, {'id':1, 'title'} Get a post by id /posts/{id} PUT {'title':'test title','content':'test content'} 204 Update a post /posts/{id} DELETE 204 Delete a post Next, we begin to create the domain model...