SpringBoot+Vue使用Get请求时提示:Error parsing HTTP request header
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot+Vue使用Get请求时提示:Error parsing HTTP request header
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
vue中使用axios請求springboot的后臺接口時需要傳遞一個int數組。
原本使用的是get請求。
export function handCompletedRequest(ids) {return request({url: '/kqgl/ddjl/dealCompleted',method: 'get',params:{ids:ids}})然后在Springboot中
??? @GetMapping("/dealCompleted")public AjaxResult dealCompleted(@RequestParam(required = true) int[] ids){return AjaxResult.success(kqDdjlService.dealCompleted(ids));}去接收,結果提示:
Error parsing HTTP request header
?
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
關注公眾號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。
實現
這是因為即使是使用params進行傳遞參數的形式,使用get請求還是將其拼接到url中,是對參數長度有限制。
所以如果是傳遞數組參數,改用post請求的方式
export function handCompletedRequest(ids) {debuggerreturn request({url: '/kqgl/ddjl/dealCompleted',method: 'post',data: ids})后臺
??? @PostMapping("/dealCompleted")public AjaxResult dealCompleted(@RequestBody(required = true) int[] ids){return AjaxResult.success(kqDdjlService.dealCompleted(ids));}?
總結
以上是生活随笔為你收集整理的SpringBoot+Vue使用Get请求时提示:Error parsing HTTP request header的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SqlServer在安装时提示:需要Mi
- 下一篇: Vue中使用Axios传递数组参数给Sp