-
1. Re: is undertow do not support multi bytes character in request form data?
ctomc Dec 30, 2016 6:07 AM (in response to benborbah)1 of 1 people found this helpfulIt does support it, but you need to specify charset for your request
-
2. Re: is undertow do not support multi bytes character in request form data?
benborbah Jan 4, 2017 10:04 AM (in response to benborbah)Thank you Tomaz !
I am sorry that the problem's root cause is something else. After debug i found that it's a jquery ajax post request like this:
$.ajax({
type: 'POST',
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
data: 'dataType=1&keyType=2&key=你好&interfaceId=1',
url: 'testctrl/formdata',
success: function (data) {alert("success")},
error:function() {alert("error")},
dataType:'xml'
});
there is chinese characters in data( key=你好 ). I add content type and specified charset to UTF-8 already, but the problem is still on.
Now i can resolve this problem in two way:
1. converting chinese character with encodeURI : data: 'dataType=1&keyType=2&key='+encodeURI('你好') + '&interfaceId=1'
2. change data to json format : data: {dataType:1,keyType:2,key:"你好",interfaceId:1}
But i still want to know if there is another way to compatible with chinese characters in data without encodeURI . I found that the charset do take place when FormDataParser creating in FormEncodedDataDefinition, but the charset seems only work for urlencoded string.