In my Spring MVC Controller I am trying to map incomming parameters to an object. My controller currently looks like this.:
@RestController("fundsConfirmationController")
@RequestMapping("/accounts/{accountId}/funds-confirmations")
public class FundsConfirmationController {
@GetMapping(
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
public ResponseEntity<?> fundsConfirmation(@PathVariable("accountId") String accountId,
@RequestBody FundsConfirmationRequestDTO fundsConfirmationRequestDTO) {
System.out.println(accountId + " " + fundsConfirmationRequestDTO);
return null;
}
As such I haven't found a way to properly combine @PathVariable
and @RequestBody
apart from setting the accountId
seperatly in the method? (I can't change the incoming parameters as these are a predefined requirement.)
Is there a proper way of combining @PathParams
and @ResponseBody
in the same Object? Without to map the Path Param in the DTO seperatly?
Any suggestion how to properly tackle this?
In case I am posting in the wrong place or I need to specify more details please correct me.
Thanks in advance, Tom