赞
踩
在controller方法中的参数前面加入@RequestBody
例:
@PostMapping
public void add(@RequestBody Obiect o) {
System.out.println(o);
}
将表单数据格式化为字符串
先安装qs库
npm i qs
在axios中的配置文件中加入如下配置即可
import Qs from "qs";
request.interceptors.request.use(config => {
if (config.method === 'put' || config.method === 'post') {
config.headers = {'Content-Type': 'application/x-www-form-urlencoded'}
config.data = Qs.stringify(config.data)
}
return config
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。