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<String> macroPath) throws IOException
{
for(String sPath :macroPath)
{
System.out.println(sPath);
}
}
本文介绍了一种使用Ajax从前端向后端批量发送文件路径进行删除操作的方法。具体包括前端利用Ajax发送POST请求并携带JSON格式的数据,以及后端接收这些数据并进行处理的过程。

861

被折叠的 条评论
为什么被折叠?



