Problems With Passing Euro Sign As URL Parameter
Solution 1:
I'm going to assume you are using Tomcat because that's what I tested with and we get the same result.
What you will want to do is open up your Tomcat servlet.xml
file and find the HTTP connector and add the useBodyEncodingForURI
attribute with the value true
.
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1"
redirectPort="8443" useBodyEncodingForURI="true">
</Connector>
Then, you will want to register a CharacterEncodingFilter
to set the HttpServletRequest
character encoding.
You can read more about this behavior in my answer here:
Solution 2:
You need indeed to encode the € sign which should give %E2%82%AC
using UTF-8
. You need to be careful with the encoding you use on both ends.
Something like URLEncoder.encode(url, "UTF-8")
on the client would do.
If you are using Spring, org.springframework.web.util.UriUtils
has also nice utilities you can use.
If the decoding issue is on the server, you need first to make sure that your web container decodes the URI with the proper encoding.
Tomcat decodes URI with ISO-8859-1
by default so you need to update your connector configuration
<Connector port="8080" ...
URIEncoding="UTF-8"/>
Solution 3:
See the following answers
- Spring MVC: How to store € character?
- Getting question mark instead accented letter using spring MVC 3
I think that org.springframework.web.filter.CharacterEncodingFilter should help here. Try it with and without your encodeURI(params)
Post a Comment for "Problems With Passing Euro Sign As URL Parameter"