JSF2西里尔语编码错误

时间:2012-03-25 20:00:10

标签: jsf-2 primefaces

我在Primefaces项目中有异化行为。 问题是,当我提交一个带有西里尔字符的h:表单时,它会变成一个? 我对á,或ç,或ñ(西班牙文字符)没有问题。

我的尝试。

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
每页都有

<?xml version="1.0" encoding="UTF-8"?>

在每个视图上。

所有xhtml文件都是UTF-8编码和类。

我制作了一个EncodingFilter

public class UTFEncodingFilter implements Filter {

public void init(FilterConfig config) throws ServletException {

}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
                                                       throws IOException, ServletException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    chain.doFilter(request, response);
}

public void destroy() {
    //No-op
}
} 

这是我的web.xml。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>my.bookingcore.com</display-name>
<welcome-file-list>
  <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>
           org.primefaces.webapp.filter.FileUploadFilter
    </filter-class>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter>
 <filter-name>UTFEncodingFilter</filter-name>
 <filter-class>com.easydevel.mybookingcore.filter.UTFEncodingFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>UTFEncodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
    <description>Refresca los JSP y los XHTML en el Tomcat</description>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
</context-param>
<context-param>
    <description>Refresca los JSP y los XHTML en el Tomcat</description>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
</context-param>
<context-param>
    <description>Refresca los JSP y los XHTML en el Tomcat</description>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
<!-- SERVLETS -->
<servlet>
    <servlet-name>ContractServlet</servlet-name>
    <servlet-class>com.easydevel.mybookingcore.servlet.ContractServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ContractServlet</servlet-name>
    <url-pattern>/getcontract</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>EstadisticasGraficaServlet</servlet-name>
    <servlet-class>com.easydevel.mybookingcore.servlet.EstadisticasGraficaServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>EstadisticasGraficaServlet</servlet-name>
    <url-pattern>/EstadisticasGrafica</url-pattern>
</servlet-mapping>

<context-param>
  <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
  <param-value>resources.application</param-value>
</context-param>
<context-param>
  <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  <param-value>client</param-value>
</context-param>
<context-param>
  <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
  <param-value>true</param-value>
</context-param>
<context-param>
  <description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
  <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
  <param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
  <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
  <param-value>true</param-value>
</context-param>
<context-param>
  <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
  <param-value>true</param-value>
</context-param>
<context-param>
 <description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
 </description>
 <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
 <param-value>true</param-value>
</context-param>
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>

我不知道我做错了什么,有什么想法吗?

Primefaces 3.01 MyFaces 2.1.6 tomcat 6

先谢谢。

0 个答案:

没有答案