我已将 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>