0

I have used Datatable to call ajax from servlet and display table on the basis of data received in response.

Although API is returning data correctly that is text containing german characters but when it comes to displaying on html in datatable its showing special character like(Gl�ckwunsch, Verk�ufer)

Initalizing Datatable:

$('#table').DataTable({
     'destroy': true,
     "sDom": 't',
     "bPaginate": false,
     "bLengthChange": false,
     "bFilter": false,
     "bInfo": false,
     "bAutoWidth": false,
     "language": {
     "url": "https://cdn.datatables.net/plug-ins/1.10.19/i18n/German.json"
      }});

When calling ajax below is my code.

$('#table').DataTable({
  'destroy': true,
  'ajax': {
    "type": "POST",
    "url": 'Servlet',
    "data": function(d) {
      // parameter sent in post
    },
    "dataSrc": ""
  },

  'columnDefs': [{
      "title": "Column1",
      "targets": 0
    },
    {
      "title": "Column2",
      "targets": 1
    }
  ],
  "deferRender": true,
  "pageLength": 25,
  'columns': [{
      "data": "Name"
    },
    {
      "data": "desc"
    }
  ],
  'dom': 'Bfrtip',

  "language": {
    "url": "https://cdn.datatables.net/plug-ins/1.10.19/i18n/German.json",
    "decimal": ",",
    "thousands": "."
  }

});

Response from API

[{
    "Name": 'ABC',
    "desc": "Glückwunsch"
}, {
    "Name": 'ABC',
    "desc": "Verkäufer"
}]

Can someone please help me over here. I didn't get anything related to this on google.

Thanks in advance

  • There could be several possible reasons why this is happening. Start with a basic one: Does the web page contain the appropriate `` tag (see [here](https://www.w3schools.com/tags/tag_meta.asp)). – andrewJames Jun 28 '20 at 16:34
  • After that, take a look at [this](https://stackoverflow.com/questions/32253895/special-character-not-displaying-as-expected), and [this](https://stackoverflow.com/questions/138948/how-to-get-utf-8-working-in-java-webapps) for more possibilities. – andrewJames Jun 28 '20 at 16:34

0 Answers0