Tuesday, 15 January 2013
Handle UTF-8 DataString ( Velocity/Struts ) -
Hey people, lately, I use a combination of strushes and velocity framework to create some websites, the problem is that when I tried UTF-8 to tell Japanese characters to input, a field name, Which I had put in the value of "索", then I click on submit (use), the data will be sent to the ad, in which I have the string name field to handle the name field The problem is that, The received string is a bit weird than the expected string "索", I have set all workstations in velocity of UTF-8. The property (input.coding / outputcoding = UTF-8), content-type / charset = UTF-8, but it always returns the strangle string, I can set the name field directly: Public Zero Setname (string name) { This.name = "索"} and confirm that fix the work, but normally add it to AddForm to name the field, someone can tell me what was wrong? Thanks for reading the patient: d.
I understand that your problem is as follows, is that correct? >
on the client browser due to mismatch:
- encoding in which the request is encoded (UTF -8 as you said) and
- encoding by which the server decodes (by default ISO-8859-1)
This can be solved by specifying the server-side encoding (up to 2) by using explicitly the CharacterEncodingFilter
of Spring Framework. / P>
(Note: Japanese frameworks such as Caesar and Teresoluna have similar filters and articles on the problem.)