No primary or default constructor found for interface java.util.List&Invalid character found in the

错误描述

最近在工作有个功能,希望能在接口中接收List</Long/>类型的数据,遇到一个问题,试了两种方式,分别报了如下错误:
No primary or default constructor found for interface java.util.List
Invalid character found in the request target [/xxx/xxx/query?packageIds[]=1349693322573
后面分析了原因都是因为参数传递不正确导致,特此来记录下。

get请求

  1. 使用Get方式,必须在参数上添加注解:@RequestParam(value = “ids”)
	@GetMapping("/xxx/query")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "xxxx", notes = "xxxx")
	public R<XxxRespVO> query(@RequestParam(value = "ids") List<Long> ids) {
		return xxx;
	}

请求方式>>>get请求: ip:8080/xxx/query?ids=1&ids=2&ids=3

post请求

  1. 使用Post方式,必须在参数上添加注解:@RequestBody
	@PostMapping("/xxx/query")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "xxxx", notes = "xxxx")
	public R<XxxRespVO> query(@RequestBody List<Long> ids) {
		return xxx;
	}

请求方式>>>get请求: ip:8080/xxx/query,在body中传递参数为:ids: [1, 2, 3 ],注意不是{ ids: [1, 2, 3 ] }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值