在GlassFish中将JSF输入提交的值的请求字符编码设置为UTF-8 [英] Set request character encoding of JSF input submitted values to UTF-8 in GlassFish

查看:178
本文介绍了在GlassFish中将JSF输入提交的值的请求字符编码设置为UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在所有< h:inputText> 字段中插入的值有问题。某些字符未按正确的方式编码。例如。如果我在输入字段中输入ciò,我会得到ciò

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.

我使用JSF 2和Facelets和GlassFish作为应用程序服务器,因为我已经有错误的值。 。

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

推荐答案

您需要告诉Glassfish使用UTF-8来解码参数,而不是(默认)ISO 8859-1。将以下条目添加到 /WEB-INF/glassfish-web.xml < glassfish-web-app> c> file:

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" />

这篇关于在GlassFish中将JSF输入提交的值的请求字符编码设置为UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆