无法在.xhtml中设置UTF-8字符编码

时间:2013-06-05 04:42:39

标签: primefaces character-encoding websphere-8

我已将xhtml设置为UTF-8和ServletRequest。但它似乎仍然无法将字符编码检测为UTF-8。我正在使用Primefaces 3.5和WebSphere 8。

.xhtml

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

RedirectLogin

public class RedirectLogin implements Filter {
  public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {

    if (request.getCharacterEncoding() == null) {
        request.setCharacterEncoding("UTF-8");
    }
    chain.doFilter(request, response);

  }
}

的web.xml

    <filter>
        <description>Redirect unauthenticated session to login page.</description>
        <display-name>RedirectLogin</display-name>
        <filter-name>RedirectLogin</filter-name>
        <filter-class>com.belsize.servlet.filter.RedirectLogin</filter-class>
        <init-param>
            <param-name>login_page</param-name>
            <param-value>/faces/login.xhtml</param-value>
        </init-param>


    </filter>
    <filter-mapping>
        <filter-name>RedirectLogin</filter-name>
        <url-pattern>/RedirectLogin</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>RedirectLogin</filter-name>
        <url-pattern>*.xhtml</url-pattern>
    </filter-mapping>

1 个答案:

答案 0 :(得分:0)

我想我的环境“很脏”。清理完项目后,重新部署,现在正常工作。