相关疑难解决方法(0)

<meta charset ="utf-8"> vs <meta http-equiv ="Content-Type">

为了定义HTML5 Doctype的字符集,我应该使用哪种符号?

  1. 短:

    <meta charset="utf-8" /> 
    
    Run Code Online (Sandbox Code Playgroud)
  2. 长:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    Run Code Online (Sandbox Code Playgroud)

html5 doctype meta-tags

1499
推荐指数
7
解决办法
107万
查看次数

i18n在JSF 2.0应用程序中使用UTF-8编码的属性文件

我正在使用jsf-ri 2.0.3,需要希伯来语和俄语支持.问题是我在屏幕上看到的是乱码而不是正确的文字.

首先,我为每种语言定义了包(*_locale.properties).这些文件采用UTF-8编码.其次,我在faces-config.xml中定义了默认和支持的语言环境

<locale-config>
    <default-locale>iw</default-locale>
    <supported-locale>en</supported-locale>
    <supported-locale>ru</supported-locale>
</locale-config>
Run Code Online (Sandbox Code Playgroud)

我添加了一个自定义过滤器,将响应字符编码设置为UTF-8.

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)

最后当我创建一个简单的xhtml来调试输出时,我看到一个非常奇怪的结果

<f:loadBundle basename="i18n.frontend.homepage" var="msg"/>
<strong>i18n: </strong><h:outputText value="#{msg.language}"/>
<br/>
<strong>Locale: </strong>
<h:outputText value="#{facesContext.externalContext.response.locale}"/>
<br/>
<strong>Encoding: </strong>
<h:outputText value="#{facesContext.externalContext.response.characterEncoding}"/>
Run Code Online (Sandbox Code Playgroud)

结果是:

i18n: ×¢×ר×ת
Locale: en_US
Encoding: UTF-8 
Run Code Online (Sandbox Code Playgroud)

我的配置有什么问题?

java jsf utf-8 internationalization jsf-2

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

doctype ×1

html5 ×1

internationalization ×1

java ×1

jsf ×1

jsf-2 ×1

meta-tags ×1

utf-8 ×1