【发布时间】:2020-11-06 13:27:06
【问题描述】:
我正在尝试根据以下代码发出带或不带参数的请求:
@RequestMapping(value = "/threshold/list", method = RequestMethod.GET)
public List<Threshold> listThreshold(@RequestParam(required = false) String categoria, @RequestParam(required = false) String kpi, @RequestParam(required = false) String data, @RequestParam(required = false) String hora) {
return thresholdQuery.listThreshold(categoria, kpi, data, hora);
}
但是当我这样调用端点时:
http://localhost:8081/threshold/list?categoria=casa
我收到以下错误:
Not enough variable values available to expand 'categoria=casa'
【问题讨论】:
-
将
@RequestParam(required = false)更改为@RequestParam(value="categoria",required = false)是否有效(与kpi、data和hora相同)? -
如何调用端点?
-
你是直接从浏览器调用它..还是你正在使用RestTemplate?如果您使用的是 RestTemplate,请分享调用此 api 的代码
-
dan1st 我做了你的更改,但仍然出现同样的错误。
标签: java spring-boot rest