国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

RESTful最佳實踐之基于 jersey 的增刪改查

2019-11-14 22:07:54
字體:
來源:轉載
供稿:網友
RESTful最佳實踐之基于 jersey 的增刪改查

jersey-rest-demo 增刪改查

項目地址:https://github.com/CoderDream/jersey-rest-demo

源代碼:http://download.csdn.net/detail/xuxiheng/8227849


查找
  1. 直接訪問 地址:http://localhost:8080/jersey-rest-demo/rest/contacts/ Image
  2. PostMan訪問 地址:http://localhost:8080/jersey-rest-demo/rest/contacts/

    查找所有的記錄:

    方法 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"         }     ] }

    Image(9)

    查找指定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" }

    Image(10)


新增
  1. 通過頁面添加: 新增:http://localhost:8080/jersey-rest-demo/pages/new_contact.jsp Image(2) 查詢:http://localhost:8080/jersey-rest-demo/rest/contacts Image(3)
  2. 通過Chrome的插件PostMan 實例1(只包含id和name):

    方法 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": "abc",     "name": "123" }

    Image(4)

    實例2(包含id、name和address列表):

    方法 PUT

    語法

    http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}

    鏈接 http://localhost:8080/jersey-rest-demo/rest/contacts/a123

    Header參數 Content-Type : application/json

    請求的json {   "address": [     {       "city": "Shanghai",       "street": "Long Hua Street"     },     {       "city": "Shanghai",       "street": "Dong Quan Street"     }   ],   "id": "a123",   "name": "Huang Yi Ming"   }

    Image(11)


修改
  1. 修改記錄

    方法 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": "abc",     "name": "12345" }

    Image(5)

  2. 查看更新后的結果

    方法

    GET

    語法

    http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}

    鏈接

    http://localhost:8080/jersey-rest-demo/rest/contacts/abc

    Header參數

    Accept : application/json

    返回的json

    {     "id": "abc",     "name": "12345" }

    Image(6)


刪除
  1. 刪除記錄

    方法 DELETE

    語法

    http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}

    鏈接 http://localhost:8080/jersey-rest-demo/rest/contacts/abc

    Header參數 Content-Type : application/json

    Image(7)

  2. 刪除后查看結果  

    方法

    GET

    語法

    http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}

    鏈接

    http://localhost:8080/jersey-rest-demo/rest/contacts/abc

    Header參數

    Accept : application/json

    Image(8)


參考文檔
  1. 在Eclipse中使用Jersey和Tomcat構建RESTful WebService及其調用

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宜章县| 泰兴市| 田林县| 台东市| 邵阳县| 龙里县| 洛南县| 大荔县| 个旧市| 历史| 合江县| 息烽县| 黎城县| 集安市| 新平| 衢州市| 巴东县| 阳泉市| 安塞县| 故城县| 农安县| 福鼎市| 柘荣县| 苗栗市| 临朐县| 商都县| 咸丰县| 神池县| 郎溪县| 广南县| 景泰县| 寿宁县| 宁远县| 泌阳县| 平南县| 四川省| 嘉荫县| 塘沽区| 平潭县| 隆子县| 凉城县|