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