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

浏览器地址栏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
发布了23 篇原创文章 · 获赞 6 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_42046751/article/details/104215471