Corrupted special characters after form submit
flopsi Oct 18, 2012 5:22 AMHi there,
i have a problem with special characters (e.g. German umlauts) when submitting a form. They are all corrupted. I am using UTF-8 all over (see below), and if i put such a corrupted character in Notepad++ and switch the view to UTF-8, then it is correctly shown...
An example of what happens:
Before form submit
After form submit
But first of all my environment (of cause there's more, but this should be all that mnatters):
JBoss 7.1.1 Final
Seam 2.3.0 Final
Mojarra 2.1.13
Hibernate Validator 4.2.0
PrimeFaces 3.3.1
I develop using JBoss Studio 5.0.1GA (UTF-8 as default encoding for text files)...
Now my configuration (the relevant part):
web.xml
======
...
<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>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
components.xml
============
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.org/schema/seam/core"
xmlns:web="http://jboss.org/schema/seam/web"
...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.org/schema/seam/components http://jboss.com/products/seam/components-2.2.xsd
http://jboss.org/schema/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.org/schema/seam/web http://jboss.com/products/seam/web-2.2.xsd
...
"
>
<core:manager concurrent-request-timeout="10000"
uri-encoding="utf-8"
conversation-timeout="1800000"
conversation-id-parameter="cid"
parent-conversation-id-parameter="pid"
default-flush-mode="MANUAL"/>
<web:hot-deploy-filter url-pattern="*.seam"/>
<web:character-encoding-filter encoding="utf-8" override-client="true" url-pattern="*.seam"/>
<web:multipart-filter disabled="true" create-temp-files="true" max-request-size="4000000" url-pattern="*.seam"/>
...
</components>
standalone.xml
===========
...
<system-properties>
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
</system-properties>
...
<profile>
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp1" protocol="AJP/1.3" scheme="http" socket-binding="ajp1" redirect-port="8443" max-post-size="4194304" max-save-post-size="8192"/>
<connector name="ajp2" protocol="AJP/1.3" scheme="http" socket-binding="ajp2" redirect-port="8443" max-post-size="4194304" max-save-post-size="8192"/>
</subsystem>
...
</profile>
...
View Template
===========
<?xml version='1.0' encoding='UTF-8'?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
contentType="text/html"
encoding="UTF-8">
...
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
...
</h:head>
</f:view>
Also i implemented a Filter to set the character set for the request:
@Scope(APPLICATION)
@Name("CharEncFilter")
@BypassInterceptors
@Install(precedence = 100)
@Filter(within = "org.jboss.seam.web.ajax4jsfFilter")
public class CharEncFilter extends AbstractFilter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
filterChain.doFilter(request, response);
}
}
So, i don't know where to put UTF-8 anymore. All XHTML files are also encoded in UTF-8. By the way, the views themselves, the message bundles and the database content show up correctly, only the submitted form data is corrupted.
I have no idea anymore, but maybe i have overseen something very obvious?!? Maybe PrimeFaces issue? But didn't find one...
Thanks a lot, best regards
Flo