1、在獲取session數據時出現亂碼:
2、html顯示出現亂碼:
3、客戶端提交中文,Servlet獲取是亂碼:
如果是get方式,在tomcat中,在conf/server.xml文件中8080端口的connector元素增加URIEncoding="utf-8"
4、Servlet提交中文,客戶端獲取亂碼
5、javascript中提交數據在服務器端獲取出現亂碼:
客戶端代碼設置:<script type="text/javascript" charset="gb2312">要爲“gb2312”,用其他的試過都不行。
服務端代碼獲取:new String(request.getParameter("name").getBytes("ISO-8859-1"),"gb2312");
6、jsp頁面中ajax提交數據後臺獲取出現亂碼
第一種情況:$.get("/AjaxServer?name="+$("#username").val(),null,function(data){});
客戶端使用編碼:gb2312,
後臺獲取採用:gb2312
第二種情況:$.ajax({
客戶端採用編碼:new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8");