1. 程式人生 > >springMVC 接收陣列引數

springMVC 接收陣列引數

關鍵是新增一個@RequestParam註解:

前臺:

//向後臺請求
$.ajax({
url:"group/defense/add/stu/selection",
type:"post",
data:{
defID:defID,
stuNums:stuNums
},
success:function(data){
alert("分配成功");
location.reload();
},
error:function(data){
alert("請求失敗");
}
});

後臺:

@RequestMapping(value = "/defense/add/stu/selection",method = RequestMethod.POST)

public void addDefStusBySel(@RequestParam(value = "stuNums[]")
String[] stuNums,Integer defID){

/*

                    */

}