elizeire elizeire - 1 year ago 108
Java Question

How set charset in a primefaces webapp?

Let me share my unique disapointment with the primefaces 3.1, until now...
I'm using a phew components in a RichFaces app, everthing fine when i realized an issue, some characters in my native language are displayed wrong, even UTF-8 charset being declared in all places i know it's required.

The problem occur when is entered some special character like "São Paulo" in a and submited the page. The data after submit is redisplays as "São Paulo"

I already tried the folowing work-around:

1)Eclipse IDE : text file enconding option

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=""
redirectPort="${jboss.web.https.port}" />


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

5)jsf file:

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

6)upgrade the primefaces version to 3.2

Thanks for any help!

Answer Source

i've been forced to create a filter who sets the charset for every request...

public class CharacterEncodingFilter implements Filter {

    public void destroy() {
        // TODO Auto-generated method stub

    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        chain.doFilter(request, response);

    public void init(FilterConfig arg0) throws ServletException {
        // TODO Auto-generated method stub


that's solve my issue