我有Spring REST控制器
@PostMapping("/complexTrace")
fun complexTrace(@RequestParam projectId: UUID, @RequestBody filter: RegulationTraceFilter): List<RegulationItemTraceResult> {
我需要调用它与@RequestParam和@RequestBody,但我不知道如何。我只知道如何传递一个主体:
val testResponse = this.resteasyClient.target("http://localhost:$port$relativePath")
.request().header("Authorization", "Bearer $accessToken").post(Entity.json(requestBody))
但是如何传递@RequestParam的值?
@RequestParam
表示查询参数。对于您的示例,URL看起来像/complexTrace?projectId=bedb3c38-4420-42ec-8151-549f285e9da8
。
您可以使用queryParam()
来配置它:
val testResponse = this.resteasyClient.target("http://localhost:$port$relativePath")
.queryParam("projectId", "bedb3c38-4420-42ec-8151-549f285e9da8")
.request().header("Authorization", "Bearer $accessToken").post(Entity.json(requestBody))