我正在尝试使用控制器发送一个字符串,比如对 AJAX 请求的响应。但不幸的是,在客户端,所有字符都变成了“?”。所有字符均来自俄语字母。我会很感激任何帮助。谢谢!这是控制器代码:
@RequestMapping("/getfield")
@ResponseBody
public Object getField(@RequestParam String fieldName) {
//returns String full of characters from russian alphabet
return pageBuilder.getMultipleChoiceField(fieldName);
}
AJAX处理:
$('#submit').click(function () {
var drop = document.getElementById('Select_chzn');
var spans = drop.getElementsByTagName('span')[0];
var chosen = spans.innerHTML;
$.post('${pageContext.request.contextPath}/getfield',
{
'fieldName': chosen
},
function (result) {
var content = document.getElementById('content');
alert(result);
content.innerHTML = content.innerHTML + result;
});
setTimeout(function() { $(".chzn-select").chosen(); }, 50);
event.preventDefault();
});
});