Monday, September 5, 2011

PrimeFaces 3.0.M3 UTF-8 encoding issues

Once PrimeFaces 3.0.M3 is added as dependency to the project, utf-8 encoding problems occur on form submits. To avoid these problems you will have to add a custom filter:
public class CharacterEncodingFilter implements Filter, Serializable 
    private static final long serialVersionUID = -4246457499875267088L;

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

    public void init(FilterConfig filterConfig) throws ServletException {

    public void destroy() {

Add this part to your web.xml:
    <filter-name>Character Encoding Filter</filter-name>
    <filter-name>Character Encoding Filter</filter-name>

After these changes are made, the utf-8 encoding problems won't occur anymore.

1 comment:

  1. Dear Sebastian

    I applied your solution to my app, it solved unicode problem but all images disappeared