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) {
  debugger
  return 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));
    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM