无法将字符集从ISO-8859-1更改为UTF-8在glassfish 3.1 [英] Unable to change charset from ISO-8859-1 to UTF-8 in glassfish 3.1

查看:248
本文介绍了无法将字符集从ISO-8859-1更改为UTF-8在glassfish 3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题将我的Web应用程序响应中的字符集从ISO-8859-1(默认)更改为UTF-8。我已经添加了VM选项 -Dfile.encoding = UTF-8 到JVM选项

I am having problems to change the charset in my web application response from ISO-8859-1 (default) to UTF-8. I already added the VM option -Dfile.encoding=UTF-8 to the JVM options

但是,请获取以下HTTP头作为glassfish的响应:

But still, I do get the following HTTP Header as a response from the glassfish:

Content-Type: [...;charset=ISO-8859-1]
Server: [GlassFish Server Open Source Edition 3.1]

您的帮助/想法。

推荐答案

-Dfile.encoding Oracle JVM特定设置如何读取Java源文件。这对HTTP响应的 Content-Type 标头中指定的字符集没有任何影响。

The -Dfile.encoding is a Oracle JVM specific setting as to how to read Java source files. This doesn't have any influence on the charset as specified in the Content-Type header of the HTTP response.

您需要将以下内容添加到 web.xml 中,以便将所有JSP的响应作为UTF-8发送,并让它在响应标头中设置相应的字符集。

You need to add the following to your web.xml in order to send the response of all JSPs as UTF-8 and to let it set the appropriate charset in the response header.

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
</jsp-config>



另请参阅:




  • Unicode - 如何获得正确的字符?

  • See also:

    • Unicode - How to get the characters right?
    • 这篇关于无法将字符集从ISO-8859-1更改为UTF-8在glassfish 3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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