Struts, UTF-8 and form submissions
Struts will convert data that is received from form submissions to a default encoding because most browsers don't set the content type.
To stop struts mangling the data you need to set the content type with a filter before it gets as far as the struts layer.
Use the filter below
You'll need to add these settings to your web.xml
Be careful how you view the output of any form submissions, for instance the console on eclipse is not UTF-8 by default.
Posted on Thursday, Feb 23, 2006

21 Comments
Your tip really saved my day!
All the best,
Armin
Keep up the good work...and thanks for saving me many hours of research..
Lance
thanks!
From : request.setCharacterEncoding("UTF8");
To: request.setCharacterEncoding("UT-F8");
From : request.setCharacterEncoding(â€UTF8″);
To: request.setCharacterEncoding(â€UTF-8″);
But on another application, I have used the same solution but it doesn't work :
my filter is the first declared in my web.xml, but the code line : request.setCharacterEncoding(â€ISO-8859-15″); seems to not work.
any idea to help me ?
I was obliged to add these attributes in order to get full (and effective) UTF-8 encoding :
URIEncoding="UTF-8" useBodyEncodingForURI="true"
NOTE : it may help jy ...
I do not know where to put or set Filter file in my ocde .. please provide me the detail of that.
The solution given is very simple and efficient
Brilliant solution!!!
Clear and Simple -- And worked right away!
It´s very useful.
It´s very useful.
Leave a Comment