I'm on spring-boot version2.6.7. Below is the controller with accepts requests with Content-Type as application/x-www-form-urlencoded.

The controller:

@PostMapping(TEAM_URL)
@Consumes({MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public String teamURL(@RequestParam @NotNull MultiValueMap<String, String> paramMap, ModelMap modelMap) {
        return teamService.teamCall(paramMap, modelMap);
}

The MultiMap in the above method is always giving size 0. It should be 1 for below request

curl --location --request POST 'http://localhost:8080/teamurl' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'XN=90-56-9p' 

This issue wasn't there with spring-boot version 2.1.6.RELEASE

Comment From: wilkinsona

I'm not sure that this is the cause of the problem but, AFAIK, @Consumes is a JAX-RS annotation and I don't think it's supported by Spring MVC. The content type that the mapping supports should be specified using the consumes attribute of the @PostMapping annotation.

Beyond that, I'm unable to reproduce the problem that you have described with Boot 2.6.7 or 2.7.1. I used this mapping:

@PostMapping(path = "teamurl", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public void whatever(@RequestParam MultiValueMap<String, String> paramMap, ModelMap modelMap) {
    System.out.println(paramMap);
}

Your example curl results in the expected single-entry map:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.7)

2022-06-27 19:18:06.227  INFO 18235 --- [           main] com.example.demo.Gh31538Application      : Starting Gh31538Application using Java 17.0.1 on wilkinsona-a01.vmware.com with PID 18235 (/Users/awilkinson/dev/workspaces/spring-projects/spring-boot/main/gh-31538/bin/main started by awilkinson in /Users/awilkinson/dev/workspaces/spring-projects/spring-boot/main/gh-31538)
2022-06-27 19:18:06.228  INFO 18235 --- [           main] com.example.demo.Gh31538Application      : No active profile set, falling back to 1 default profile: "default"
2022-06-27 19:18:06.814  INFO 18235 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-06-27 19:18:06.821  INFO 18235 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-06-27 19:18:06.821  INFO 18235 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.62]
2022-06-27 19:18:06.882  INFO 18235 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-06-27 19:18:06.883  INFO 18235 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 611 ms
2022-06-27 19:18:07.115  INFO 18235 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-06-27 19:18:07.122  INFO 18235 --- [           main] com.example.demo.Gh31538Application      : Started Gh31538Application in 1.148 seconds (JVM running for 1.382)
2022-06-27 19:18:10.117  INFO 18235 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-06-27 19:18:10.117  INFO 18235 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-06-27 19:18:10.118  INFO 18235 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
{XN=[90-56-9p]}

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.