一、Get

$.ajax({
type: "get",
url: "url地址",
async: true,
dataType:"json",//返回数据类型
success: function(data){
console.log(data);
}
});

二、Post

var data = {
"id": "",
"name": "",
...
}; $.ajax({
type:"post",
url: "url地址",
async:true,
data: JSON.stringify(data),//后台接受时使用了@RequestBody注解,需要Json字符串和指定contentType
contentType:"application/json;charset=utf-8",
dataType: "json",
success: function(data){
alert("数据准备: successful");
console.log(data);
}
});

三、Put(待测试)

四、Delete

var data = {
"id": "",
"name": "",
...
}; $.ajax({
type:"DELETE",
url: "url地址",
async:true,
contentType:"application/json",//设置请求参数类型为json字符串
data:JSON.stringify(data),//将json对象转换成json字符串发送
dataType:"json",
success:function(result){
alert(result);
} });

SpringBoot之RESTFul风格的接口调用(jQuery-Ajax)的更多相关文章

  1. 使用SpringBoot编写Restful风格接口

    一.简介    Restful是一种对url进行规范的编码风格,通常一个网址对应一个资源,访问形式类似http://xxx.com/xx/{id}/{id}. 举个栗子,当我们在某购物网站上买手机时会 ...

  2. Restful风格API接口开发springMVC篇

    Restful风格的API是一种软件架构风格,设计风格而不是标准,只是提供了一组设计原则和约束条件.它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机 ...

  3. RestKit ,一个用于更好支持RESTful风格服务器接口的iOS库

    简介 RestKit 是一个用于更好支持RESTful风格服务器接口的iOS库,可直接将联网获取的json/xml数据转换为iOS对象. 项目主页: RestKit 最新示例: 点击下载 注意: 如果 ...

  4. SpringBoot之RESTful风格

    SpringBoot之RESTful风格 1.RESTful介绍 RESTful是一种软件架构风格,一种时尚! RESTful架构风格规定,数据的元操作,即CRUD(create, read, upd ...

  5. SpringBoot RestFul风格API接口开发

    本文介绍在使用springBoot如何进行Restful Api接口的开发及相关注解已经参数传递如何处理. 一.概念: REST全称是Representational State Transfer,中 ...

  6. SpringBoot实战(二)Restful风格API接口

    在上一篇SpringBoot实战(一)HelloWorld的基础上,编写一个Restful风格的API接口: 1.根据MVC原则,创建一个简单的目录结构,包括controller和entity,分别创 ...

  7. java框架之SpringBoot(6)-Restful风格的CRUD示例

    准备 环境 IDE:Idea SpringBoot版本:1.5.19 UI:BootStrap 4 模板引擎:thymeleaf 3 效果:Restful 风格 CRUD 功能的 Demo 依赖 &l ...

  8. SpringBoot 动态代理实现三方接口调用

    目录 一.定义注解 二.建立动态代理类 三.注入spring容器 四.编写拦截器 五.创建客户端调用类 六.main方法测试 七.启动项目 在某些业务场景中,我们只需要业务代码中定义相应的接口或者相应 ...

  9. Springboot+Dubbo使用Zipkin进行接口调用链路追踪

    Zipkin介绍: Zipkin是一个分布式链路跟踪系统,可以采集时序数据来协助定位延迟等相关问题.数据可以存储在cassandra,MySQL,ES,mem中.分布式链路跟踪是个老话题,国内也有类似 ...

随机推荐

  1. yii---进行接受参数

    GET接受参数: Yii::$app->request->get($key, $default):第一个参数($key)为用户get请求的key,第一个参数选填:第二个参数($defaul ...

  2. thinkphp结合layui上传图片

    简单示例: <script type="text/javascript"> layui.use(['form', 'layedit','element', 'layda ...

  3. linux 安装Swagger(swagger-editor , swagger-ui)

    一.环境要求 1.Nodejs ( 版本6.0x以上 ) 2.npm (npm 3.x) 注: linux 更新nodejs到最新 node -v 4.2.1 sudo npm cache clean ...

  4. Java工程师之Redis实战系列教程前言&目录

    系列前言 Java工程师之Redis实战系列教程,同其他教程一样,均是在下学习笔记,本系列主要参考自<Redis-in-action>,将书本中的有趣的例子转化为能解决特定问题的示例程序, ...

  5. C#控制台窗口居中显示(转)

    private struct RECT { public int left, top, right, bottom; } [DllImport("kernel32.dll", Se ...

  6. 浙江工业大学校赛 小M和天平

    小M和天平 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  7. SPOJ Distinct Substrings【后缀数组】

    Given a string, we need to find the total number of its distinct substrings. Input T- number of test ...

  8. consul Consul vs. ZooKeeper, doozerd, etcd

    小结 1.Consul 功能更丰富: 2. 暴露http接口避免暴露系统复杂性 The Consul clients expose a simple HTTP interface and avoid ...

  9. stack overflow underflow

    Introduction to algorithms / Thomas H. Cormen...[etal.].—3rded. If we attempt to pop an empty stack, ...

  10. 前端开发组件化设计vue,react,angular原则漫谈

    前端开发组件化设计vue,react,angular原则漫谈 https://www.toutiao.com/a6346443500179505410/?tt_from=weixin&utm_ ...