ajax调用中的波兰字符编码问题

我在ajax调用中遇到波兰字符的问题。 在以下代码中显示的警报中,抛光字符未正确显示。

$.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); } }); 

以下是Controller类的方法

 public void getAllApps(HttpServletRequest request, HttpServletResponse response){ Gson gson = new Gson(); List moduleList = moduleDao.getAllActiveModulesByDomain(domain.getDomainId()); try { if(moduleList != null && moduleList.size()> 0){ response.getWriter().print(gson.toJson(moduleList)); } catch (Exception e) { e.printStackTrace(); } } 

确保您使用的是CharacterEncodingFilter ,在web.xml中添加以下内容

  encoding-filter  org.springframework.web.filter.CharacterEncodingFilter   encoding UTF-8   forceEncoding true    encoding-filter /*  

您还可以确保为tomcat正确配置服务器,例如将URIEncoding添加到连接器

  

将指定用于解码URI的字符编码。 您应该找到服务器的等效项

最后,如果问题仍然存在,请检查数据库的解码以及与数据库的连接是否也已正确设置