jersey-rest-demo 增删改查
项目地址:https://github.com/CoderDream/jersey-rest-demo
源代码:http://download.csdn.net/detail/xuxiheng/8227849
查找所有的记录:
方法 GET
语法
http://localhost:8080/jersey-rest-demo/rest/contacts
链接 http://localhost:8080/jersey-rest-demo/rest/contacts
Header参数 Accept : application/json
返回的json { "contact": [ { "address": [ { "city": "Shanghai", "street": "Long Hua Street" }, { "city": "Shanghai", "street": "Dong Quan Street" } ], "id": "huangyim", "name": "Huang Yi Ming" }, { "id": "a1", "name": "a1" } ] }
查找指定ID的记录:
方法 PUT
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接 http://localhost:8080/jersey-rest-demo/rest/contacts/abc
Header参数 Content-Type : application/json
返回的json
{ "id": "a1", "name": "a1" }
请求的json
{ "id": "abc", "name": "123" }
实例2(包含id、name和address列表):
链接 http://localhost:8080/jersey-rest-demo/rest/contacts/a123
请求的json { "address": [ { "city": "Shanghai", "street": "Long Hua Street" }, { "city": "Shanghai", "street": "Dong Quan Street" } ], "id": "a123", "name": "Huang Yi Ming" }
请求的json { "id": "abc", "name": "12345" }
方法
GET
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/abc
Header参数
Accept : application/json
{ "id": "abc", "name": "12345" }
方法 DELETE