RESTful最佳实践之基于 jersey 的增删改查
jersey-rest-demo 增删改查
项目地址:https://github.com/CoderDream/jersey-rest-demo
源代码:http://download.csdn.net/detail/xuxiheng/8227849
查找
直接访问
地址:http://localhost:8080/jersey-rest-demo/rest/contacts/
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/contactsHeader参数
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/abcHeader参数
Content-Type : application/json返回的json
{
"id": "a1",
"name": "a1"
}
新增
通过页面添加:
新增:http://localhost:8080/jersey-rest-demo/pages/new_contact.jsp
查询:http://localhost:8080/jersey-rest-demo/rest/contacts通过Chrome的插件PostMan
实例1(只包含id和name):
方法
PUT语法
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/abcHeader参数
Content-Type : application/json请求的json
{
"id": "abc",
"name": "123"
}实例2(包含id、name和address列表):
方法
PUT语法
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/a123Header参数
Content-Type : application/json请求的json
{
"address": [
{
"city": "Shanghai",
"street": "Long Hua Street"
},
{
"city": "Shanghai",
"street": "Dong Quan Street"
}
],
"id": "a123",
"name": "Huang Yi Ming"
}
修改
修改记录
方法
PUT语法
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/abcHeader参数
Content-Type : application/json请求的json
{
"id": "abc",
"name": "12345"
}查看更新后的结果
方法
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"
}
删除
删除记录
方法
DELETE语法
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/abcHeader参数
Content-Type : application/json删除后查看结果
方法
GET
语法
http://localhost:8080/jersey-rest-demo/rest/contacts/{contactId}
链接
http://localhost:8080/jersey-rest-demo/rest/contacts/abc
Header参数
Accept : application/json
参考文档
RESTful最佳实践之基于 jersey 的增删改查的更多相关文章
- Mybatis_3.基于注解的增删改查
1.实体类User.java public class User { private int id; private String name; private int age; //getter.se ...
- ASP.NET Web API基于OData的增删改查,以及处理实体间关系
本篇体验实现ASP.NET Web API基于OData的增删改查,以及处理实体间的关系. 首先是比较典型的一对多关系,Supplier和Product. public class Product { ...
- [转]ASP.NET Web API基于OData的增删改查,以及处理实体间关系
本文转自:http://www.cnblogs.com/darrenji/p/4926334.html 本篇体验实现ASP.NET Web API基于OData的增删改查,以及处理实体间的关系. 首先 ...
- 系统操作命令实践 下(系统指令+增删改查+vim编辑器)
目录 1.考试 2.今日问题 3.今日内容 4.复制文件 4.移动文件 Linux文件查看补充 cat , nl 5.删除文件 6.系统别名 7.vi/vim编辑器 系统操作命令实践 下(系统指令+增 ...
- 30分钟用Restful ABAP Programming模型开发一个支持增删改查的Fiori应用
2016年时,Jerry曾经写过一系列关于SAP Fiori Smart Template(现在更名为Fiori Elements了)的博客,介绍了所谓的MDD开发方法论 - Metadata Dri ...
- Node.js、express、mongodb 入门(基于easyui datagrid增删改查)
前言 从在本机(win8.1)环境安装相关环境到做完这个demo大概不到两周时间,刚开始只是在本机安装环境并没有敲个Demo,从周末开始断断续续的想写一个,按照惯性思维就写一个增删改查吧,一方面是体验 ...
- Mybatis_2.基于XML的增删改查
1.实体类User.java public class User { private int id; private String name; private int age; //getter.se ...
- 基于django做增删改查组件,分页器组件
增删改查组件 一.Djangoadmin的启发 二.基于Djangoadmin实现数据的增删改查 分页器组件 分页器组件的介绍以及源码解读 补充:源码下载,
- CRM基于.NET的增删改查
一.准备工作: 1.添加 microsoft.crm.sdk.proxy.dll和microsoft.xrm.sdk.dll 引用到项目中!并引用以下using! using Microsoft.Xr ...
随机推荐
- AS3 Post 参数和ByteArray的方法及服务器端接收
as端: (form表单形式)req.method = URLRequestMethod.POST; var reqHeader:URLRequestHeader = new URLRequestHe ...
- 将从数据库中获取的数据 ,以HTML表格的形式显示
1.HTML页面 <body> <form id="form1" runat="server"> <div id="di ...
- Median of Two Sorted Arrays-分治法
题目意思很简单将两个有序数组合并之后的中位数找出来.题目要求使用log(m+n)的时间复杂度来做. 虽然言简意赅,但不得不承认这个题目我自己想了好久也没做出来,隐约觉得应该使用寻找第k大数的算法来做, ...
- 【Linux命令】配置ssh远程连接步骤
安装ssh: sudo apt-get update sudo apt-get install openssh-server 查看ssh服务器是否启动: sudo ps -e | grep ssh 查 ...
- Django内置template标签
html过滤{% autoescape on|off %} {{body}} {% endautoescape %} 注释{% comment %} {% endcomment %} csrf攻击 { ...
- 405 HTTP method GET is not supported by this URL
孙鑫java web开发详解P285里面提交Get网站弹出提示405 HTTP method GET is not supported by this URL 原因父类doGet()方法未覆盖. 应写 ...
- 转:C++:从子类访问父类的私有函数
众所周知,c和c++的数组都是不安全的,因为无论c还是c++都不提供数组边界检查功能,这使得数组溢出成为可能.从某个意义上说,c和c++是一种缺少监督的语言,然而这也正是其魅力所在.c++给予程序员更 ...
- Linux UDEV和为MySQL InnoDB共享表空间配置裸设备
⑴ UDEV 基础 udev 可管理保存在/dev 目录下的文件.文件只有在接入相应设备后才会生成.设备被拔出后自动删除 它还允许用户添加规则.以便修改/dev中默认的名称和权 ...
- kinit manual
Name kinit - obtain and cache Kerberos ticket-granting ticket Synopsis kinit [-V] [-l lifetime] [-s ...
- Js基础操作
var a="zhangsan"; document.write(a+":I love JavaScrip"); a="lisi"; doc ...