【发布时间】:2014-07-24 20:20:28
【问题描述】:
我有一个 jqgrid,我可以在其中上传英语/法语/俄语的数据。当我上传俄语字符时,它显示为一些无效符号。像……??? ??
我把jsp页面的编码改成了<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
在 jq 配置中有什么具体要更改的吗?请帮忙。 以下是我的 Jquery 实现
jQuery('#studentLst')
.jqGrid(
{
url : endpoint,
datatype : 'json',
rownumbers : true,
height : 250,
colNames : [ 'StudentID', 'Name', 'Marks','Description' ],
colModel : [ {
name : 'sId',
index : 'sId',
hidden : true
}, {
name : 'name',
index : 'name',
}, {
name : 'marks',
index : 'marks',
width : 200
},{
name : 'description',
index : 'description',
width : 190,
sortable : false
}],
multiselect : false,
rowNum : 10,
rowList : [ 10, 20, 40, 60, 80, 100 ],
viewrecords : true,
autowidth : true,
caption : 'Student List',
onSelectRow : function(ids) {
//Load sub grids
},
gridComplete : function() {
//Implementation
},
loadComplete : function(response) {
},
onPaging : function(pgButton) {
$("#studentLst").setGridParam({
datatype : 'json'
});
},
pager : "#studentLstPg"
});
jQuery('#studentLst').navGrid('#studentLstPg', {
search : false,
addfunc : function() {
//add student
},
addtitle : 'Add Student',
editfunc : function() {
//update student info implementation
},
edittitle : 'Edit Student',
delfunc : function() {
// Show confirmation box and delete the student
},
deltitle : "Delete Student"
});
var grid = jQuery("#studentLst");
};
【问题讨论】:
-
您是否真的以
UTF-8格式保存文件(html/jsp 页面)? -
@Oleg 我在网格中加载的动态数据是多语言的。
-
很明显,您动态加载数据,您必须发布更多实现细节。如果你能正确地做所有事情,你就不会有问题。因此,需要查看更多实现细节来找出您犯了哪些错误。尝试在 html/jsp 页面上直接包含一些俄语文本,并验证您是否有同样的问题。例如,您的数据库或访问数据库的方式可能存在问题。
-
@Oleg 我已经更新了 jquery 实现。
-
您是否将俄语文本直接放在 jqGrid 之外的 html/jsp 页面(如
<span>Привет!</span>)上?你看对了文字吗?从url : endpoint返回的data 有问题吗?您是否验证了Fiddler 或开发者工具(按 F12 启动,然后在网络选项卡中启动跟踪)从服务器返回的数据是正确的?
标签: javascript jquery jqgrid