springmvc 传递和接收数组参数
java url中如何传递数组,springMVC框架controller类如何接收数组参数?
下面介绍一下URL中传递数组参数方法:
dd.php?titles[]=col1&titles[]=col2&titles[]=col3
或者使用ajax方式传递:
var param = {titles:['col1','col2','col3']}; $.ajax({url:"dd.php", type:"post", data:param, async:false, dataType:"json", cache:false, error:function (data) { rtnObj = data.responseText; }, beforeSend:function (XMLHttpRequest) { //ajaxStart(); }, complete:function (XMLHttpRequest, textStatus) { //ajaxComplete(); }, success:function (data) { rtnObj = data; }});
在springMVC中controller类接收数组参数的方法:
@RequestMapping(value="/save", method = RequestMethod.POST) @ResponseBody public String save(@RequestParam(value = "titles[]") String[] titles){ System.out.println(titles); return null; }
顶
踩
相关文章:
- springmvc 表单提交时间字段_springMVC form提交404
- springmvc 添加传参自定义异常
- 解决org.springframework.beans.factory.BeanCreation
- springmvc form表单提交后台对象获取不到值(解决)
- springmvc form提交使用@ModelAttribute后台取得乱码
- (解决) springmvc jsp界面显示乱码 spring+mybatis+my
- spring jar framework 下载地址(解决)
- Field or property 'jobParameters' cannot be found
- MINA2官方教程翻译(10)与Spring整合
- spring Bean property 'backupService' is not writab