Spring 无法正确解码 form-urlencoded 值

Spring can't properly decode form-urlencoded value

我已经阅读了,因为我的问题与问题类似,但现在我卡住了。
通过 Postman,我以这种方式发送数据:

在 Spring 中,我这样检索它们:

@PostMapping(path = PathConstants.START_ACTION, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public ResponseEntity<BaseResponse<ProcessInstance>> start(@PathVariable String processDefinitionId,
            @RequestParam("username") String params) {

这是有效的,我可以打印用户名的值:

System.out.println("Username " + params);

问题是我需要发送的所有参数,但我无法将它们作为字符串或任何其他对象获取,因为我会发出很多不同的请求,但并非所有请求都有 "username" 字段,顺便说一句,我需要收集所有这些。
我怎样才能做到这一点? 我试过

 @PostMapping(path = PathConstants.START_ACTION, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public ResponseEntity<BaseResponse<ProcessInstance>> start(@PathVariable String processDefinitionId,
            @RequestParam String params) {

@PostMapping(path = PathConstants.START_ACTION, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    public ResponseEntity<BaseResponse<ProcessInstance>> start(@PathVariable String processDefinitionId,
             String params) {

如其他答案中所建议,但在这些情况下 params 为空。什么是正确的工作方式?

您的方法中需要 @RequestBody 注释,我建议使用 MultiValueMap:

@PostMapping(path = PathConstants.START_ACTION, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<BaseResponse<ProcessInstance>> start(@PathVariable String processDefinitionId, @RequestBody MultiValueMap<String, String> params)