How to set encoding in web-interface?

Let me share my unique disappointment with performances 3.1, so far ... I use phew components in RichFaces application, everything is fine when I understood the problem, some characters in my native language are not displayed correctly, even UTF-8 encoding is declared in all places, I know this is necessary.

The problem arises when entering some special character, such as "São Paulo", in a and sending the page. The data after sending is re-displayed as "SÃÂ £ o Paulo"

I have already tried the following work:

1) Eclipse IDE: the ability to view a text file

2) jsf files:

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

3) JBOSS server.xml:

 <Connector protocol="HTTP/1.1" URIEncoding="UTF-8" port="${jboss.web.http.port}" address="0.0.0.0" redirectPort="${jboss.web.https.port}" /> 

4) web.xml:

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

5) jsf file:

 <h:form acceptcharset="UTF-8" enctype="application/form-data"> 

6) update the price list version to 3.2

Thanks for any help! ; -)

+7
source share
2 answers

I had to create a filter that sets the encoding for each request ...

 public class CharacterEncodingFilter implements Filter { @Override public void destroy() { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.setCharacterEncoding("UTF-8"); request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); } @Override public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } } 

who solve my problem

+9
source

I just uncomment this part in conf / web.xml (Tomcat server web.xml), which filters the entire request and converts to UTF-8.

  <!-- A filter that sets character encoding that is used to decode URIs--> <!-- parameters in a POST request --> <filter> <filter-name>setCharacterEncodingFilter</filter-name> <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <!-- The mapping for the Set Character Encoding Filter --> <filter-mapping> <filter-name>setCharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 
+1
source

All Articles