我发现了一个问题,试图从包含土耳其字符的ajax调用中更新Postgres数据库(UTF-8)。我有一个带有id和name属性的简单json,名称包含'Kumar oyunlarışıtaşır‘,数据库上保存的是"Kumar oyunlar��risk ta����r“。
$(document).ready(function () {
$("#sendToServer").click(function(){
var json = '{"name":"Kumar oyunları risk taşır", "id": 123'};
var server = "http://10.16.0.89:8080";
var apiURL = server + "/api/content/publish/create";
var dataform = new FormData();
dataform.append('json', JSON.stringify(json));
getURL = $.ajax({
url: apiURL,
type: 'PUT',
cache: false,
data: dataform,
contentType:false,
success: function (result, request, response, data, status, xhr) {
alert('Success!');
}
});
});
...
<button id="sendToServer">Send to server</button> 如果使用json而不是dataform ( data: json )没有问题,但是我真的需要它来使用它,因为我必须在我的应用程序中追加一个文件。
发布于 2018-02-26 15:18:31
问题出在Tomcat方面,我只是遵循这样的解决方案:Character encoding issue with Tomcat和它现在运行得很完美。
https://stackoverflow.com/questions/48947902
复制相似问题