-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation on reading form data via Servlet request parameters vs @RequestBody
#33409
Comments
The change of behavior seems to have been introduced in Spring Framework 6.1:
|
In Spring Boot Spring Boot Both uses Tomcat 10.1.x. |
Likely a regression caused by gh-31327 (via 8fa428f) as you have already found @membersound (could have been nice to mention it in the issue description, please share all your findings next time please). |
@rstoyanchev As I lack a bit of context on those changes, could you please provide guidance on how to handle this when you are back? |
In the Servlet API, request parameter access causes the request body to be parsed, and it can't be read again, e.g. via In 6.0.x we accepted an optimization in I think the best thing is to not rely on the feature, which can only be properly implemented at the level of the Servlet container. In other words don't expect to be able to read form data via @PostMapping(value = "/example", consumes = APPLICATION_FORM_URLENCODED_VALUE)
public Mono<String> namedsqlPostForm(@RequestParam MultiValueMap<String, String> params) {
// ...
} |
Based on @rstoyanchev feedback, I am turning this regression issue to a documentation one. @membersound Please follow Rossen's guidance for your use case. |
@RequestBody
I upgraded from spring-boot v2 -> v3. My tests could not detect the following issue, even though I tested the scenario.
The following problem does only occur in live, but not in tests:
In the following example, the
@RequestBody
parameters are missing in case when using additionalquery parameters
.The following works (body params are filled in controller):
The following fails (body params are missing in controller):
Result LIVE:
I attached a sample, which fails in live mode, but succeeds in junit test mode.
Switching the example back to spring-boot 2.x, also the live mode works.
Test:
spring-web-example.zip
The text was updated successfully, but these errors were encountered: