如何在浏览器地址栏中,直接把数组参数写到url中进行传递 ?

丶灬走出姿态 提交于 2020-02-08 03:38:59
浏览器地址栏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

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!