1

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

.xhtml

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

重定向登录

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>
4

1 回答 1

0

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

于 2013-06-05T16:32:30.207 回答