vue前端使用axios发请求时报错:uncaught (in promise) Error: Request failed with status code 400。

报错如图: 

前端代码:

const pushdata=(postdata,callback)=>{
  console.log(postdata)
  axios.get(portUrl+ 'comments/putdata',postdata)
      .then(()=>{
          // location.reload()
          }
      )}

后端代码(看到用@RequestBody就知道是前端发json格式的post了):

其实原因很简单,因为发的是post请求,应该将axios.get改成axios.put.....

猜你喜欢

转载自blog.csdn.net/Zhongtongyi/article/details/111518649