spring mvc接收数组
(一)前言
对于springmvc接收数组的问题啊,我试验过几次,但是了有时候成功了,有时候失败了,也不知道为啥的,然后现在又要用到了,所以打算具体看看到底怎么回事,但是了我实验成功了顺便找了好多资料的。
(二)spring mvc接收数组测试代码

@ResponseBody
@RequestMapping(value = "/test/array", method = RequestMethod.POST)
public JSON test(@RequestParam(value = "ids[]") String[] ids){
for(int i=0;i<ids.length;i++){
System.out.println(ids[i]);
}
JSON jsonStr=JSON.parseObject("{hehe:123456}");
return jsonStr;
}

然后自己新建一个网页,引入jquery.js,我用的google浏览器,然后按F12就如开发者模式,在console里面写下如下的js
$.post("test/array",{"ids":["haha","123456","xixi"]},function(data){console.info(data);});

测试结果如图,而且你也可以在你的后台打印处看见相应的打印数据。
在这之前查找过得资料可以借鉴先
http://blog.csdn.net/z69183787/article/details/41653843这里面有一些不经常用到的传值方式,url上传入多个值,后台用数组接收
http://www.cnblogs.com/digdeep/p/4589037.html
http://www.jsjtt.com/java/Javakuangjia/67.html
(三)总结
这几天重新敲以前的代码,自己不用做前端,感觉不错,只是觉得天天敲后台代码好枯燥,还好抽时间看了看python。精通才重要,好多东西都是敲多了就懂了,但是了还是需要自己去了解,比如看源码等
spring mvc接收数组的更多相关文章
- 【spring mvc】后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate ...
- 使用Spring mvc接收整个url地址及参数时注意事项
使用Spring mvc接收整个url地址及参数时注意事项:url= http://baidu?oid=9525c1f2b2cd45019b30a37bead6ebbb&td=2015-08- ...
- spring mvc接收ajax提交的JSON数据,并反序列化为对象
需求:spring mvc接收ajax提交的JSON数据,并反序列化为对象,代码如下: 前台JS代码: //属性要与带转化的对象属性对应 var param={name:'语文',price:16}; ...
- Spring MVC接收参数(Map,List,JSON,Date,2个Bean)(记录一次面试惨状)
题目Spring MVC 接收参数 MapListDate2个BeanJSON Spring MVC接收参数 -Map Spring MVC接收参数 -List Spring MVC接收参数 -dat ...
- spring mvc 接收页面表单List
很少写博客,如果写的不好请多多包涵! 最近在用Spring mvc时遇到一个问题,在网上搜了很多资料.几乎没看到解决办法! 例如:当我们在做批量添加或者更新时,在Controller层接收表单数据的问 ...
- Spring MVC 接收Json格式参数
今天做了一个关于表格排序的功能,可以通过右边的箭头做排序操作,每次操作需要通过Ajax将每条记录的Id数组作为参数去发送请求, 后台Spring MVC接到参数后作更改序号操作. 前端页面发送请求的代 ...
- spring mvc接收JSON格式的参数
1.配置spring解析json的库 <dependency> <groupId>org.codehaus.jackson</groupId> ...
- 如何让Spring MVC接收的参数可以转换为java对象
场景: web.xml中增加了一个DispatcherServlet配置,并在同级目录下添加了**-servlert.xml文件,搭建起了一个spring mvc的restful访问接口. 问题描述: ...
- spring mvc接收List集合、JUI传JSP List
JUI页面是这样的 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <div class=&quo ...
随机推荐
- Codeforces 332B Maximum Absurdity(DP+前缀和处理)
题目链接:http://codeforces.com/problemset/problem/332/B 题目大意:给你n个数和一个整数k,要求找到不相交的两个长度为k的区间,使得区间和最大,输出这两个 ...
- HDU 1669 Jamie's Contact Groups(多重匹配+二分枚举)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1669 题目大意: 给你各个人可以属于的组,把这些人分组,使这些组中人数最多的组人数最少,并输出这个人数 ...
- Es官方文档整理-3.Doc Values和FieldData
Es官方文档整理-3.Doc Values和FieldData 1.Doc Values 聚合使用一个叫Doc Values的数据结构.Doc Values使聚合更快.更高效且内存友好. Doc Va ...
- LeetCode828. Unique Letter String
https://leetcode.com/problems/unique-letter-string/description/ A character is unique in string S if ...
- Elasticsearch介绍及安装部署
本节内容: Elasticsearch介绍 Elasticsearch集群安装部署 Elasticsearch优化 安装插件:中文分词器ik 一.Elasticsearch介绍 Elasticsear ...
- ViewPager中的子Activity无法响应OnActivityResult的解决方法
ViewPager子Activity通过startActivityForResult()跳转至OtherActivity,OtherActivity回传结果由ViewPager所在的父Activity ...
- jquery插件使用记录
1.imgPreview(图片预览功能插件) demo地址:http://james.padolsey.com/demos/imgPreview/full/
- canvas 笔记整理
canvas Retina 屏幕优化 /** * HiDPI Canvas Polyfill (1.0.9) * * Author: Jonathan D. Johnson (http://jonda ...
- USACO 6.3 Cowcycles
CowcyclesOriginally by Don Gillies [International readers should note that some words are puns on co ...
- windows7无声音,提示未插入扬声器或耳机的解决
windows7无声音,提示未插入扬声器或耳机的解决: http://jingyan.baidu.com/article/358570f6043a85ce4624fc47.html