zoukankan      html  css  js  c++  java
  • 前端AJAX传递数组给Springmvc接收处理

    前端传递数组后端(Spring)来接收并处理:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>测试页面</title>
    <script type="text/javascript" src="http://www.ostools.net/js/jquery/jquery-1.7.2.js"></script>
    <script type="text/javascript">
    function ccc() {
    	var btn = document.getElementById("btn");
    	$.ajax({  
    		type:'post',  
    		                  url:'http://localhost:8080/event/add.do',  
    		                  data: {url:["www.baidu.com","www.qq.com"]},
    		                  dataType:'text',//服务器返回的数据类型 可选XML ,Json jsonp script htmltext等  
    		                  success:function(msg){  
    		                          },  
    		                  error:function(){  
    		                  alert('error');  
    		                  }  
    		        }) 
    }
    
    </script>
    </head>
    <body>
        <div>
            <button id="btn" onclick=ccc()>点击测试</button>
        </div>
    </body>
    </html>
    

      后端:

     @RequestMapping(value = "add")
        public void add( @RequestParam(value = "url[]",required = false,defaultValue = "") String[] url,
                                    HttpServletResponse response)
        {
            
         System.out.println(url)
            
        }
  • 相关阅读:
    webrtc 手机端视频旋转
    gstreamer 命令行一些demo
    git一些命令记录
    libnice的问题记录
    webrtc ice 协商一些记录
    linux 挂在windows目录
    leetcode Permutation Sequence
    gstreamer 接收rtsp存储为h264
    uva 10285
    AndroidStudio VS Eclipse快捷键
  • 原文地址:https://www.cnblogs.com/byteworld/p/5953902.html
Copyright © 2011-2022 走看看