java - jQuery DataTables does not show Unicode characters -


i using jquery datatables show pagination data mysql database.

when show normal characters in table, shows proper data in table. but, when save unicode characters shows ? characters.

the following html codes page:

<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>township</title> <link rel="stylesheet" href="<c:url value="/resources/styles/township.css" />"/> <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0/css/jquery.datatables.css"> <script type="text/javascript" charset = "utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript" charset = "utf8" src="//cdn.datatables.net/1.10.0/js/jquery.datatables.js"></script> <script type="text/javascript" charset = "utf8" >  //plug-in fetch page data  jquery.fn.datatableext.oapi.fnpaginginfo = function ( osettings ) {     return {         "istart":         osettings._idisplaystart,         "iend":           osettings.fndisplayend(),         "ilength":        osettings._idisplaylength,         "itotal":         osettings.fnrecordstotal(),         "ifilteredtotal": osettings.fnrecordsdisplay(),         "ipage":          osettings._idisplaylength === -1 ?             0 : math.ceil( osettings._idisplaystart / osettings._idisplaylength ),         "itotalpages":    osettings._idisplaylength === -1 ?             0 : math.ceil( osettings.fnrecordsdisplay() / osettings._idisplaylength )     }; };  $(document).ready(function() {  $("#example").datatable( {     "bprocessing": true,     "bserverside": true,     "sort": "position",     "bstatesave": false,     "idisplaylength": 10,     "idisplaystart": 0,     "fndrawcallback": function () {      },              "sajaxsource": "springpaginationdatatables.web",     "aocolumns": [          { "mdata": "townshipcode" },         { "mdata": "townshipname" },         { "mdata": "divisionname" },         { "mdata": "actionlink"},      ] } );  } );  </script> </head> <body> <div id="container">     <div id="table">         <form:form action="" method="get" align="center">             <br>             <table style="border: 3px;background: rgb(243, 244, 248); width: 90%; margin:20px auto;"><tr><td>                 <table id="example" class="display">                     <thead>                         <tr>                         <th>code</th>                         <th>township</th>                         <th>division</th>                         <th>action</th>                     </tr>                 </thead>                    </table>             </td></tr></table>             <br>         </form:form>      </div> </div> </body> </html> 

my backend java code table is:

@requestmapping(value = "/springpaginationdatatables.web", method = requestmethod.get, produces = "application/json") public @responsebody string springpaginationdatatables(httpservletrequest  request) throws ioexception {      integer pagenumber = 0;     if (null != request.getparameter("idisplaystart"))         pagenumber = (integer.valueof(request.getparameter("idisplaystart"))/10)+1;           integer pagedisplaylength = integer.valueof(request.getparameter("idisplaylength"));      list<township> listtownship = townshipdao.getlist(pagenumber, pagedisplaylength);     int count = townshipdao.getcount();      jsonobject<township> townshipjsonobject = new jsonobject<township>();     //set total display record     townshipjsonobject.setitotaldisplayrecords(count);     //set total record     townshipjsonobject.setitotalrecords(count);     townshipjsonobject.setaadata(listtownship);      gson gson = new gsonbuilder().setprettyprinting().create();     string json2 = gson.tojson(townshipjsonobject);      return json2; } 

i got following output in data table showing ? instead of unicode characters:

enter image description here

please me solve problem.

try forcing charset in produces attribute so:

@requestmapping(value = "/springpaginationdatatables.web", method = requestmethod.get, produces = "application/json; charset=utf-8")


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -