我使用服务器端jquery DataTable来显示数据列表。列表中有一些俄罗斯(西里尔文)数据。我们通过数据库获取数据并将其放入JSONObject中,此对象由DataTable获取但是我得到了??? ????代替俄罗斯人物。
在Jsp页面,我使用了
在标题%@page contentType="text/html; charset=UTF-8" %
在控制器中,我使用了
@RequestMapping(value = "view/{list}", method = RequestMethod.POST, produces={"application/json; charset=UTF-8","/;charset=UTF-8"})
public void getList(ModelMap model, @RequestParam String showAll, HttpServletRequest request, HttpServletResponse response) throws IOException, JSONException {
JSONObject result = new JSONObject(); PrintWriter out = response.getWriter();
try { //some code here
result = (JSONObject) abcDao.getList();
response.setContentType("application/json");
response.setHeader("Cache-Control", "no-store");
response.setCharacterEncoding("UTF-8");
out.print(result);
model.put("result", result);
} catch (Exception e) {
logger.error("", e);
}
}
JavaScript代码:
oTable = $('#test_table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bLengthChange": true,
"bAutoWidth": false,
"aLengthMenu": [[5, 10, 25, 50, 100, 200, 500], [5, 10, 25, 50, 100, 200, 500]],
sPaginationType: "bootstrap",
iDisplayLength: parseInt($("#recordsPerPage").val()),
"sAjaxSource": "aa/view/getData.do",
"aoColumns" : [
{"sTitle":"Status","sWidth" : "2%",sClass: "font-th","bSortable" : false,"aTargets": [ 0 ] },
{"sWidth" : "6%","bSortable" : true },
{"sWidth" : "5%","bSortable" : true },
{"sWidth" : "17%","bSortable" : true }
],
"aaSorting": [[1, 'desc']],
"oLanguage": {
"sLengthMenu": $('#datatTableRecordsPerPage').html()+"_MENU_",
"oPaginate": {
"sPrevious": $('#dataTablePaginationPrevious').html(),
"sNext": $('#dataTablePaginationNext').html()
},
"sSearch": $('#dataTableSearchField').html(),
"sZeroRecords":$('#datatTableZeroRecords').html(),
"sInfo": $('#datatTableInfoShowing').html()+" _START_ "+$('#datatTableInfoTo').html()+" _END_ "+$('#datatTableInfoOf').html()+" _MAX_ "+$('#datatTableInfoEntries').html(),
"sProcessing":$('#Processing').html()
},
"sDom": '<"row-fluid"<"span4" <"span5" l>> <"span8"<"span8" <"paginationName"> p><"span2 searchStyle" f> >><"row-fluid"<"span3" ir>>t<"row-fluid"<"span4" i><"span4 lowerPaginationStyle" p>>',
"fnDrawCallback": function( oSettings ) {
},
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
aoData.push({"name":"incidentId", "value":encodeURIComponent(id) },{"name":"msgType", "value":msg},{"name":"showAll", "value":'' }),
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"headers": {
'CRI_TOKEN': critoken
},
"contentType": "application/x-www-form-urlencoded;charset=utf-8",
"data": aoData,
"success": function(data){
fnCallback(data);
}
} );
}
});
请帮我弄清楚我错在哪里。