bkahlert edited a comment on issue #232: Fix handling of query parameters with 
no value, like `?foo`
URL: https://github.com/apache/tomcat/pull/232#issuecomment-575914702
 
 
   I fear we won't make progress here.
   To anyone who suffers from the same problem (I spent hours with it),
   I have created a workaround as a [gist - 
UndefinedToNullMappingWebMvcRegistrationsConfiguration.java](https://gist.github.com/bkahlert/47884a44edcbbff8da5e79696f428eff)
 that makes Spring Boot always parse the query string not just the same way as 
during the tests but also as you might expect it; `undefined` / `?foo`  as 
`null` and `defined` / `?bar=&baz=%F0%9F%90%BB` as what it is (empty string and 
🐻).
   
   ```
   @Override
   public Map<String, String[]> getParameterMap() {
       MultiValueMap<String, String> parameterMap = UriComponentsBuilder
           .fromHttpRequest(new 
ServletServerHttpRequest(getRequest())).build().getQueryParams();
       return parameterMap.entrySet().stream().collect(Collectors.toMap(
           Map.Entry::getKey, entry -> entry.getValue().toArray(new 
String[0])));
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to