Set request character encoding of JSF input submitted values to UTF-8 in GlassFish

99封情书 提交于 2020-01-14 09:16:10

问题


I have a problem with the values inserted in all my <h:inputText> fields. Some characters are not encoded in the right way. E.g. if I put ciò in the input field I get ciò.

How can I allow a user to insert text with those characters and save them correctly? The problem in not in the DB encoding since I already have the wrong value before inserting it in the DB.

I'm using JSF 2 with Facelets and GlassFish as application server.


回答1:


You need to tell Glassfish to use UTF-8 to decode paramters instead of (default) ISO 8859-1. Add the following entry to the <glassfish-web-app> of your /WEB-INF/glassfish-web.xml file:

<parameter-encoding default-charset="UTF-8" />


来源:https://stackoverflow.com/questions/9682476/set-request-character-encoding-of-jsf-input-submitted-values-to-utf-8-in-glassfi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!