I am getting issue for polish characters in ajax call. In alert shown in below code, polish characters are not coming properly.
$.ajax({
type: "GET",
url: "/module/getAllApps.htm",
encoding:"UTF-8",
contentType:"application/x-www-form-urlencoded; charset=UTF-8",
async: true,
success : function(response) {
if(response != null && response != "" && response!= '' && response != 'null'){
var appList = JSON.parse(response);
for(var i=0; i<appList.length; i++){
var module = appList[i];
alert(module.title);
}
}
},
error : function(e){
console.log('Error: ' + e);
}
});
Below is method from Controller class
public void getAllApps(HttpServletRequest request, HttpServletResponse response){
Gson gson = new Gson();
List<Module> moduleList = moduleDao.getAllActiveModulesByDomain(domain.getDomainId());
try {
if(moduleList != null && moduleList.size()> 0){
response.getWriter().print(gson.toJson(moduleList));
} catch (Exception e) {
e.printStackTrace();
}
}
Ensure that you're using the CharacterEncodingFilter, add the following in your web.xml
You can also make sure that your server is configured properly, for tomcat for instance adding URIEncoding to connector
will specify the character encoding used to decode the URI. You should find an equivalent for your server
Finally, if you're problem persists, check that the decoding of your DB and your connection to the DB is also properly set