SpringMvc 能夠接收將前端傳遞的數組,可使用轉換爲List<T>或者數組接收前端
前端作法:java
$.ajax({ type:'post', url :'test', data:{ name : 'nick', kind : [20,30,40] } })
後端接收:ajax
<!-- lang: java --> @RequestMapping("test") public void test(String name, @RequestParam(value = "kind[]", defaultValue = "") List<Integer> kind, HttpServletRequest request, Writer writer) { }