I have a field that I can insert a certain name and find the user with the correspondent name,that was developed in react. My code works when that name is like "test", but if the name is like "this test" (if the name has a space on it), my backend receives the name in this format ("this%20test") and when I am searching for that name on the database, the entry returns null. How can I solve this? I want to solve this on my frontend because I think it´s the best option.
Asked
Active
Viewed 369 times
0
-
It seems you are passing parameter as query params thats why they are getting url encoded, in your backend url decode the paramter to get the actual value. If you send the parameter in POST body, you will not face this issue. – Hemant Patel Mar 30 '19 at 18:40
-
And how do I decode it? – jose azevedo Mar 30 '19 at 18:42
-
Added answer, please check – Hemant Patel Mar 30 '19 at 18:45
1 Answers
1
Any parameters passed as query params will be url-encoded and passed to your backend. You need to url decode parameters in your backend.
See this to url decode in java https://stackoverflow.com/a/6138183/3295987

Hemant Patel
- 3,160
- 1
- 20
- 29
-
I have a similar problem in react,I have a card componet and the card has a button.If the name of the card doesn´t have a space on it a popup will open (which is supposed to) but if the name has a space on it,the popup won´t open,can I update my question so you can help me on that? – jose azevedo Mar 30 '19 at 19:07
-
-