Encrypted? You're kidding. Most likely you actually meant Mojibake.
In order to avoid Mojibake, you need to ensure that you use the one and the same character encoding throughout your entire application while producing and consuming characters. These days UTF-8 is a sane choice if you want world domination. JSF2 defaults to UTF-8 all the time already. So your problem is somewhat strange.
Perhaps you're actually using PrimeFaces? It's known to mess the default UTF-8 character encoding when an ajax request is been fired. That part is answered here, you'd need to create a servlet filter.
Or perhaps the value is actually correct, but you're printing the value to an output which does not support UTF-8 at all and thus you incorrectly identified the cause of the problem? E.g. via System.out.println()
in Eclipse console. You'd need to configure it via Window > Preferences > General > Workspace > Text file encoding as answered here.
Or perhaps you explicitly forced the JSF2 encoding to something different by <f:view encoding>
, e.g. to ISO-8859-1
. You should not do that, remove the encoding
attribute from the <f:view>
and keep it default.
Or very perhaps your MySQL DB/table encoding is not UTF-8 at all, but that would not match the problem symptoms you described, or you must have omitted the part that you're actually printing the value retrieved from the DB instead of the value retrieved from the form submit.
In any case, everything you need to know about character encoding in Java EE web applications, complete with all possible problems and solutions is elaborated in Unicode - How to get the characters right?