views:

770

answers:

2

Hello,

I'm using Struts2. When I send 'special' characters like ä or ã through a form, the actions that receive it display those characters differently (like à + a little square). I know that I have an encoding problem, but I was unable to find where the request encoding can be configured for Struts2.

Can anyone please help me ?

Best regards,

Nils

A: 

Answering my own question :

links should always be URL-encoded. The s:url encoding set to true does not seem to work properly (or misused ? But I doubt) and it works with the old good c:url.

Nils
+1  A: 

Hi, you should use character encoding filter. just put in web.xml a filter, before struts filter action. See below

<filter>
    <filter-name>CharacterEncodingFilter</filter-name>
    <filter-class>your.pkg.CharacterEncodingFilter</filter-class>
</filter>

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>

Just type your code in your encoding filter to character encoding "UTF-8". I added header page encoding with UTF-8 too.

That's solve the problem. I have ever experienced that problem too.

Jef