0

I have a get request with this param in the url (encoded in cp1252):

?c=es&t=a%20coru%F1a

I have a Spring Boot service with a QueryParam that automatically converts to:

a coru�a

The %20 are replaced by spaces and the %F1 are replace by �

If I try to encode again:

java.net.URLEncoder.encode(t, "Windows-1252");

This is the final result (%3F instead %F1)

a+coru%3Fa  

What I need is the QueryParam doesn't decode the url, I only want that string as a I send it.

If I try with POST request and x-www-form-urlencoded everything works fine (obviously), but I need GET request.

Luisao
  • 455
  • 2
  • 9
  • 20
  • Did you try re-encoding (double encoding) that string and sending? like `a%2520coru%25F1a` – Udith Gunaratna Nov 30 '21 at 07:51
  • Hi, I can't modify the string I send (actually, others send) – Luisao Nov 30 '21 at 07:58
  • All URL parameters should be encoded and decoded with `UTF-8` See [What charsets should be used for url encoding](https://stackoverflow.com/questions/29276432/what-charsets-should-be-used-for-url-encoding) The client that is making the get request is doing it wrong. This isn't your problem, the client needs to be modified. – Stephen Ostermiller Nov 30 '21 at 11:03
  • yes, i know, but it's pretty difficult to change that, thx anyway! – Luisao Nov 30 '21 at 13:19

1 Answers1

0

This is what i did it at the end:

I've changed @RequestParam by:

HttpServletRequest request

And then:

request.getQueryString()

And I can get the values from the query url in the same format.

Probably it's not the best option, but it works!

Thanks.

Luisao
  • 455
  • 2
  • 9
  • 20