springMVC 前台向后台传数组

前台:

[java] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. $(function() {//点击播放按钮执行的事件  
  2.                             $("#button").click(function(e) {  
  3.                                 alert("kaishi chuanzhi ");  
  4.                                 var ids = [];     
  5.                                 var i = map.size();  
  6.                                 var allValue = map.values();              
  7.                                 for (i; i < allValue.length; i++) {                  
  8.                                 ids.push(allValue[i]);            
  9.                                 }  
  10.                             //  window.href="${ctx}/sitesmanage/video/form?id=${type.id}"  
  11.                             //  window.location.href = "videShowChilds.do?id=" + id;  
  12.                                 $.ajax({   
  13.                                  type: 'POST',   
  14.                                  url:'${ctx}/sitesmanage/video/videoPlay',  
  15.                                  dataType : "json",  
  16.                                  data:{titles:ids},  
  17.                                   error: function (XMLHttpRequest, textStatus, errorThrown) {   
  18.                                       alert(textStatus);   
  19.                                   },   
  20.                                   success: function (data) {   
  21.                                        
  22.                                     alert("ok");  
  23.                                           
  24.                                   }   
  25.                               });   
  26.                               
  27.                             });  
  28.   
  29.                         });  

后台:

 

[java] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. @RequestMapping(value = "videoPlays")  
  2.     public String videoPlays(HttpServletRequest request,  
  3.             HttpServletResponse response, ModelMap model,@RequestParam(value = "titles[]") String[] titles) {  
  4.         System.out.println(titles.length+"@@@");  
  5.         //return "modules/sitesmanage/videoPlayForm";  
  6.     return null;  
  7.     }  
posted @ 2017-03-08 17:23  左正  阅读(772)  评论(0编辑  收藏  举报