I have the follwing code inside a facelet page:
<h:inputNumber value="bean.property">
<f:convertNumber type="currency" />
</h:inputNumber
The converter is because there can be a kind of default value inside the input field, which comes from the bean property. Everything is rendered correctly. The value inside the input field is rendered with an “€” character (e.g. “1.453 €”.
When I submit the form there comes an error up:
"nameOfInputField" konnte nicht als ein Geldbetrag erkannt werden '304,00 â¬'
In english it is some like:
"nameOfInputField" could not be regognized as an amount of money '304,00 â¬'
Please have a look at the “€” character. It seems to be printed as “⬔. While it was rendered correctly before submitting the form, now it looks like “⬔ inside the error message and inside the input field.
All pages are encoded in UTF-8.
What is the reason for this error?
How can fix it?
Thanks in advance
This is typical for the € from an original UTF-8 source which is incorrectly been decoded using ISO-8859-1. Here’s a small snippet which demonstrates that:
You’re likely talking about response encoding. You need to set the request encoding as well.
To set the encoding for
GETrequests (basically: URI encoding), you need to consult the appserver specific documentation. As it’s unclear which one you’re using, here’s a Tomcat targeted example:<Connector URIEncoding="UTF-8" />. To set the encoding forPOSTrequests, you need to create a simple filter which doesrequest.setCharacterEncoding("UTF-8")if it isnull. More background information and hints can be found in this article.