Restful传递数组参数的两种方式
第一种,直接传递数组
- js直接传递数组
var data = ["123","456"];
that.loadDictionarys(data).subscribe({
next: res => {
},
error: err => {
}
});
- 后端接口直接接收数组
@POST
@Path("/loadDictionarys")
@Produces({ MediaType.APPLICATION_JSON, FastJSONProvider.TEXT_JSON, FastJSONProvider.TEXT_FASTJSON })
public RestResponse loadDictionarys(String[] dicItemCodeArr) {
Map<String, DictionaryVO> dictionaryVOs = new HashMap<>();
RestResponse successResult = RestResponse.successResult(dictionaryVOs);
return successResult;
}
第二种,通过json对象传递
- js组装json对象传递数组
var data = {
arr:["123","456"]
};
that.loadDictionarys(data).subscribe({
next: res => {
},
error: err => {
}
});
- 后端接口通过@FormParam注解可用String集合接收
@POST
@Path("/loadDictionarys")
@Produces({ MediaType.APPLICATION_JSON, FastJSONProvider.TEXT_JSON, FastJSONProvider.TEXT_FASTJSON })
public RestResponse loadDictionarys(@FormParam("arr") List<String> arr) {
Map<String, DictionaryVO> dictionaryVOs = new HashMap<>();
RestResponse successResult = RestResponse.successResult(dictionaryVOs);
return successResult;
}
Restful传递数组参数的两种方式的更多相关文章
- 【前台 ajax】web项目前台传递数组给后台 两种方式
项目使用maven springMVC 有需求 将前台的数组 在ajax中 送给后台 方式1: 前台代码:[注意:ajax中的属性---traditional:true, ] 如果Post ...
- java中数组复制的两种方式
在java中数组复制有两种方式: 一:System.arraycopy(原数组,开始copy的下标,存放copy内容的数组,开始存放的下标,需要copy的长度); 这个方法需要先创建一个空的存放cop ...
- C++ 数组遍历的两种方式
C++ 数组遍历的两种方式: #include <iostream> using namespace std; int main() { // 一维数组 ] = {, , , , }; / ...
- 传递引用类型参数的两种方式(转自 MSDN)
引用类型的变量不直接包含其数据:它包含的是对其数据的引用.当通过值传递引用类型的参数时,有可能更改引用所指向的数据,如某类成员的值(更改属性的值),但是无法更改引用本身的值:也就是说,不能使用相同的引 ...
- Express全系列教程之(四):获取Post参数的两种方式
一.关于POST请求 post方法作为http请求很重要的一部分,几乎所有的网站都有用到它,与get不同,post请求更像是在服务器上做修改操作,它一般用于数据资源的更新.相比于get请求,post所 ...
- jmeter请求参数的两种方式
Jmeter做接口测试,Body与Parameters的选取 1.普通的post请求和上传接口,选择Parameters. 2.json和xml请求接口,选择Body. 注意: 在做接口测试时注意下请 ...
- hibernate createQuery查询传递参数的两种方式
String hql = "from InventoryTask it where it.orgId=:orgId"; Session session = getSession() ...
- mybatis 传递参数的两种方式与模糊匹配 很重要
- mysql存储过程中遍历数组字符串的两种方式
第一种:多次使用substring_index()的方法 DELIMITER $$ DROP PROCEDURE IF EXISTS `array`$$ CREATE PROCEDURE `arra ...
随机推荐
- Sqlserver日期操作
Sqlserver日期操作 select GETDATE() as '当前日期', DateName(year,GetDate()) as '年', DateName(month,GetDate()) ...
- 使用display:flex;实现垂直水平居中
body,div{margin:0px;padding:0px;} .flex-container{display:flex;height:300px;background-color:#ddd;ju ...
- scrapy xpath中提取多个class值
xpath中没有提供对class的原生查找方法.但是 stackoverflow 看到了一个很有才的回答: This selector should work but will be more eff ...
- P1452 Beauty Contest
传送门 求凸包周长,用旋转卡壳,具体可见yyb大佬的博客 顺便一提这题暴力+随机化也能过 暴力代码 //minamoto #include<bits/stdc++.h> #define r ...
- [转]Linux命令wc的详细用法
转自:http://blog.hehehehehe.cn/a/17301.htm wc命令用来打印文件的文本行数.单词数.字节数等(print the number of newlines, word ...
- fastjson读取json配置文件
fastjson读取json配置文件: ClassLoader loader=FileUtil.class.getClassLoader(); InputStream stream=loader.ge ...
- SQL Sever语言 事务
事务:保障流程的完整执行保证程序某些程序在运行时同时成功同时失败,保证程序的安全性 begin tran --在流程开始的位置加 --此处写SQL语句 if @@error>0 --ERRORS ...
- vs项目结构解析
当我们用VS开发一个项目的时候,首先应该清楚用VS这个IDE生成的一些文件和文件夹是什么意思,起什么作用,什么场合下使用. 因为我使用的是VS2015,就以这个为例来进行一些说明: 首先要做的是更改你 ...
- 研磨JavaScript系列(一):回归简单
想要理解JavaScript,你得首先放下对象和类的概念,回到数据和代码的本原.编程世界只有数据和代码两种基本元素,而这两种元素又有着纠缠不清的关系.JavaScript就是把数据和代码都简化到最原始 ...
- Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>"的解决办法
看老师的word文档开始学习.复制了一段代码,在layout中新建了一个Android XML file,发现有提示错误. 代码如下: <?xml version="1.0" ...