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
Add queryParam method to MockHttpServletRequestBuilder #23296
Comments
You can supply a URL with a query to |
@rstoyanchev I know, that's why I mentioned it.
Every other part of the the request has a structured way to set it except the querystring, which requires manual encoding and concatenation. An alternative is to add |
Apologies I missed that part of your comment. I don't see providing the query in the URI template as a workaround. It is the primary way of specifying the target URI with all of its components including the query. The URI template by the way is encoded so I do not see a need for manual encoding. And you can also use That said we can add a queryParam method as an extra convenience, and that will append to query of the target URI. |
This is now superseded by #23980. |
ServletUriComponentsBuilder
usesHttpServletRequest#getQueryString
to build on the current request.However, in a GET or HEAD request,
MockHttpServletRequestBuilder#param
only adds to the combined parameter map and not the query string, causing it to fail.The workaround is to provide the parameters directly in the URI string, but this is inferior to the fluent API. The different behaviour is probably surprising to many users.
See also spring-projects/spring-restdocs#26
The text was updated successfully, but these errors were encountered: