Struts2 requests character encoding

I am using Struts2. When I send "special" characters, such as Γ€ or Γ£, through the form, the actions that receive it display these characters differently (for example, Γƒ + a small square). I know that I have an encoding problem, but I could not find where to configure the request encoding for Struts2.

Can anybody help me?

Yours faithfully,

Niels

+1
encoding character struts2 request
source share
2 answers

Answering my own question:

References

Must always be URL encoded. The s: url encoding set to true does not seem to work properly (or is it being used incorrectly? But I doubt it), and it works with the old good c: url.

+2
source share

You must use a character encoding filter. just put in the web.xml filter before the 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 enter your code into your encoding filter into the "UTF-8" character encoding. I also added header encoding with UTF-8.

This is the solution to the problem. I also have ever experienced this problem.

+4
source share

All Articles