How to Pass Multiple Path Variables for Spring Boot Controller Class in Get Method?
I Am Trying to Pass Multiple Path Variables to My Controller Class in Get Method, So I Am Giving Variables Through Postman, When I Tried for Single Variable...
i am trying to pass multiple path variables to my controller class in GET method, so i am giving variables through POSTMAN, When i tried for single variable it's working fine, but for two variables i am getting empty result.
This is how i am passing variables through POSTMAN localhost:8081/specquestions/java/oops
here 'java' is one variable and 'oops' is one more variable
My java controller class
@RequestMapping(method=RequestMethod.GET,value="/specquestions/{subject}/{topic}")
public ResponseEntity<List<QuestionBank>> getSpecificQuestions(@PathVariable String subject,String topic) {
return ResponseEntity.ok( questionBankService.getSpecificquestions(subject,topic));
}
Can any one please suggest me where i did mistake.
1 Answer
Just add @PathVariable for second parameter in controller like below
@RequestMapping(method=RequestMethod.GET,value="/specquestions/{subject}/{topic}")
public ResponseEntity<List<QuestionBank>> getSpecificQuestions(@PathVariable String subject,@PathVariable String topic) {
return ResponseEntity.ok( questionBankService.getSpecificquestions(subject,topic));
}