这是vue
axios({
method:'post',
url: "http://localhost:8000/api/download" ,
headers:{
"Content-Type":"multipart/form-data;boundary=<calculated when request is sent>",
'Authorization':this.$cookies.get('Authorization')
},
data: {
path: this.$data.paths + '\/' + name // /123/Login.JPG
},
responseType: 'blob'
这是控制类接收
public void downLoad(@RequestParam("path") String path
结果是浏览器发送失败
报错:
Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'path' for method parameter type String is not present]
但是postman请求就成功
学艺不精 哭 求指点
form data格式的数据需要这样传
const formData = new FormData()
formData.append('path', this.$data.paths + "\/" + name)
axios({
method: "post",
url: "http://localhost:8000/api/download",
headers: {
"Content-Type": "multipart/form-data;boundary=<calculated when request is sent>",
Authorization: this.$cookies.get("Authorization"),
},
data: formData,
responseType: "blob",
});
有配置跨域吗?端口不一样也属于跨域