告诉我,如何在Feign客户端或其他客户端的参数中设置默认值?
这是我的代码。我指定了默认值,但它不起作用:(
服务:
public Price get(PricesRequest request) {
return priceFeignClient.get(
request.getPrice(),
request.getAddress(),
request.getCode(),
request.getCurrency()
)
}
假客户:
public interface PriceFeignClient {
@GetMapping
Price get(@RequestParam("price") String price,
@RequestParam("address") String Address,
@RequestParam(value = "code", required = true, defaultValue = "AAA") String code,
@RequestParam("currency") String currency
);
我想为“ code”参数设置默认值。
解决问题的方法如下:
将其添加到我敲过的服务器上的主api中(即,在接收方,而不是在发送方请求上。)>
(而不是required = true)。@RequestParam(value = "code", required = false, defaultValue = "AAA") String code
Required是required = false