前端 (需要qs库)
const t = {
title: "vue",
content: "123"
, tags: ["66", "777"]
};
axios({
url: "http://localhost:8000/bmsPost/sendPost",
method: "post",
data: qs.stringify(t, {arrayFormat: 'repeat'})
});
后端
@RequestMapping("/sendPost")
public void sendPost(String title, String content, String[] tags) {
System.out.println(title);
System.out.println(content);
System.out.println(Arrays.toString(tags));
}
注意
arrayFormat 不同参数区别
const t = {
title: "vue",
content: "123"
, tags: ["66", "777"]
};
console.log(qs.stringify(t, {arrayFormat: 'indices'}));
console.log(qs.stringify(t, {arrayFormat: 'brackets'}));
console.log(qs.stringify(t, {arrayFormat: 'repeat'}));
url解码后:
差别就在这里。