axios post请求-FormData上传文件 作者:马育民 • 2022-09-14 20:48 • 阅读:10488 # 说明 可以实现 **表单方式提交** 的效果,后端代码可以用 `request.getParameter()` 方式接收参数 而且可以 **上传文件** **post发送数据方式:** `Content-Type: multipart/form-data` ### 前端代码 ``` ``` # 发送头信息 ``` axios.post('http://localhost:8080/web_war_exploded/testJWT', '',{ headers: { 'auth': localStorage.getItem('auth') } }) .then(res => { console.log(res); }) .catch(erro => {// 请求失败处理 console.log(error); }); ``` 原文出处:http://malaoshi.top/show_1IX432ffakyd.html