外观和参数



通常,带有分页的rest具有带有Criteria和Paging的方法我需要使用Feign方法调用这些方法,但我有错误:

Method has too many Body parameters

我的方法调用是:

@RequestMapping(value = "/server/myRequest", method = RequestMethod.GET)
public ResponseEntity<String> getMyRequestByCriteriaClient(@RequestHeader("Authorization") String authHeader, CriteriaCustom criteria, Pageable pageable);

(CriteriaCustom是一个简单的pojo,带有getter和setter(

在其他方面,我有:

@GetMapping("/myRequest")
public ResponseEntity<String> getMyRequestByCriteriaServer(CriteriaCustom criteria, Pageable pageable) {...}

如何编写客户端电话?我尝试在Map<字符串,对象>和@RequestParam,但它们没有到达服务器端。

我不敢相信使用Feign调用并向服务器传递条件和分页是不可能的。这是一个简单的GET!!!

这是因为您在GET请求中将CriteriaCustomPageable作为主体传递,而服务器很乐意忽略这一点。在您的情况下,有两个主体,因此出现错误-Method has too many Body parameters

因此,您可以将它们作为Map<字符串,对象>RequestParams,或者你可以编写自己的编码器,它可以为你所有的假动作做到这一点。你可以在这里找到代码。

最新更新