7

I have below code in my controller:

@RequestMapping(value = "/child/{nodeId}/{relType}",method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON)    
public Iterable<Node> getConnectedNodes(@RequestParam("page")int page, @RequestParam("size")int size, @PathVariable("nodeId") String nodeId, @PathVariable("relType") String relType) {
    return nodeService.getConnectedNodes(nodeId, relType,page,size);    
}

And this is the API URL I am hitting

http://localhost:8080/node/child/e17a64ff-dc2b-49b1-a995-67dba9413d67/Collegues?page=0&size=1

Here in debug mode I can see values of path variables, i.e. nodeId and relType, but can not see values of request param page and size which I am passing through my request in URL above.

What's wrong with @RequestParam?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
mahendra kawde
  • 855
  • 4
  • 25
  • 44

2 Answers2

3

Can you try with below snippet:

@RequestMapping(value = "/child/{nodeId}/{relType}",method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON)    
public Iterable<Node> getConnectedNodes(@RequestParam(value="page", required=false) int page, @RequestParam(value="size", required=false) int size, @PathVariable("nodeId") String nodeId, @PathVariable("relType") String relType) {
    return nodeService.getConnectedNodes(nodeId, relType,page,size);    
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
0

@Parameter(name = "nodeId", in = ParameterIn.PATH)

@Parameter(name = "relType", in = ParameterIn.PATH)*

@RequestMapping(value = "/child/{nodeId}/{relType}",method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON)
public Iterable getConnectedNodes(@RequestParam("page")int page, @RequestParam("size")int size, @PathVariable("nodeId") String nodeId, @PathVariable("relType") String relType) { return nodeService.getConnectedNodes(nodeId, relType,page,size);

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '23 at 15:37