杰克逊映射器具有特殊字符é问题 [英] jackson mapper with special character é issue
问题描述
我有一个网页,提交了一个像这样的字符JoséLuisCalleja Garcia
Hi i have web page which submits a charecter say like this José Luis Calleja Garcia
但是在服务器将其转换为JoséLuisCalleja Garcia
。
But in the server its get converted to José Luis Calleja Garcia
.
我不知道我做错了什么。我应该设置什么配置才能得到它JoséLuisCalleja Garcia
。
I dont know what i am doing wrong. what configuration i should set to get it as José Luis Calleja Garcia
.
我正在提交像这样的多部分请求在角度服务中
I am submitting the multipart request like this in angular service
var config = {
method: "POST",
url: 'some url',
headers: { 'Content-Type': false },
transformRequest: function (data) {
var formData = new FormData();
formData.append("model", angular.toJson(data.getFormDefinition()));
for (var i = 0; i < data.files.length; i++) {
formData.append(data.files[i].name, data.files[i]);
}
return formData;
},
data:requestModel
};
我的服务器端对象映射器配置是这样的
And my server side object mapper configuration is like this
public class CustomViewObjectMapper extends ObjectMapper{
public CustomViewObjectMapper() {
super();
this.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
this.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
this.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
}
}
感谢提前的帮助
推荐答案
é的Unicode代码点是U + 00E9,在UTF-8中变为0xC3 0xA9。现在,在ISO-8859-1中,0xC3是Ã,而0xA9是©。因此,您似乎以UTF-8发送数据,但将其解释为ISO-8859-1。
The Unicode code point for é is U+00E9, which becomes 0xC3 0xA9 in UTF-8. Now, in ISO-8859-1, 0xC3 is Ã, and 0xA9 is ©. So, it seems that you are sending the data in UTF-8, but interpreting it as ISO-8859-1.
或者,您可以尝试添加内容类型标题:
Or, you could try adding a content type header:
Content-Type: application/json; charset=utf-8
以确保服务器正确解释它。
to make sure the server interprets it correctly.
这篇关于杰克逊映射器具有特殊字符é问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!