浏览器地址栏Url直接传数组,写法如下:
localhost/addTopic?topicArr=testTcC&topicArr=testTcD
或者
localhost/addTopic?topicArr=testTcC,testTcD
controller接收数组,如下:
@RequestMapping("/addTopic")
public String addTopic(String[] topicArr){
System.out.println("打印接收到的数组: "+ Arrays.toString(topicArr));
return "OK";
}
错误写法:
localhost:81/addTopic?topicArr={"testTcC","testTcD"}
localhost:81/addTopic?topicArr[]=testTcC&topicArr[]=testTcD