Bonjour à tous,
Je développe une application java/JEE, j'ai un composant Jquery (Datatable) qui affiche le résutat de mon service de recherche sous forme d'une response Json.
Mon problème c'est que les caractère avec accents s'affichent comme ca "�".
Voila le header de ma JSP:
La méthde de recherche dans mon controller:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="false"%> <!doctype html> <html lang="fr"> <head> <meta charset="utf-8"> <title>App</title> <link href="resources/css/CA-BANK-theme/jquery-ui-1.10.1.custom.css" rel="stylesheet"> <script type="text/javascript" charset="utf-8" src="resources/js/jquery-1.9.1.js"></script> <script type="text/javascript" charset="utf-8" src="resources/js/jquery-ui-1.10.1.custom.js"></script> <script type="text/javascript" charset="utf-8" src="resources/js/jquery.dataTables.js"></script> <style type="text/css" title="currentStyle"> @import "resources/css/data-table-css/table_jui.css"; </style> <script type="text/javascript" charset="utf-8"> $(function() { var oTable; oTable = $("#myTable").dataTable({ bJQueryUI : true, sPaginationType : "full_numbers", iDisplayLength : 8, "bLengthChange" : false, "bSort" : false, "oLanguage" : { "sUrl" : "resources/language/fr.txt" }, "bProcessing" : true, "bServerSide" : true, cache : false, "sAjaxSource" : "/app/welcome/recherche", "fnServerData" : function(sSource, aoData, fnCallback) { $.ajax({ "dataType" : 'json', "type" : "POST", "url" : sSource, "data" : aoData, "success" : fnCallback }); } });
Après plusieurs tests, il me semble que le parser coté client ne parse pas la reponse Json en UTF-8, comment faire pour résoudre ce problème?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 @RequestMapping(value="/recherche", method = {RequestMethod.POST, RequestMethod.GET}) public @ResponseBody String recherche(@RequestParam String sSearch, @RequestParam String sEcho, @RequestParam String iDisplayStart) throws IOException, ParseException { String str = "{ \"sEcho\": "+Integer.valueOf(sEcho)+" ," + " \"iTotalRecords\": 0," + " \"iTotalDisplayRecords\": 0," + " \"aaData\": [" + " ]" + "}"; if((sSearch!=null)&&(sSearch.length()>0)){ String searchCriteria = sSearch;//+"*"; List<Activity> activityList = searchService.getActivities("C:/Indexation/src/main/resources/index", searchCriteria, 999); Map<String, String> result = jsonService.getJsonResponse(activityList, sEcho); str = result.get(iDisplayStart); return str;
Merci d'avance,
Partager