springmvc controller层接收List类型的参数

1.前台通过ajax传输数据

var allFilePaths = new Array();

for (var i = 0; i < 10; i++) {
    allFilePaths.push("xx"+i);
}
$.ajax({  
    url : url,
    type : 'POST',
    dataType: 'json',
    contentType: "application/json",
    data : JSON.stringify(allFilePaths),
    success : function(col) {

    }
    },
    error : function(col){
            }
});

2.controller层

@RequestMapping("/delFileInfo")
@ResponseBody
public void delFileInfo(@RequestBody List macroPath) throws IOException 
    {

        for(String sPath :macroPath)
        {
            System.out.println(sPath);
        }
    }

你可能感兴趣的:(web框架)