This article is mainly on the jquery.ajax in the URL to pass the Chinese garbled problem solving method is introduced, the need for friends can come to the reference, I hope to be helpful to everyone
jquery jquery Default contenttype:application/x-www-form-urlencoded This is why jquery is garbled, when the character set is not specified, Is the use of iso-8859-1 iso8859-1, usually called Latin-1. Latin-1 includes additional characters that are indispensable for writing all Western European languages. jquery Ajax does not take into account the internationalization of the problem, the use of the European character set, so it caused the transfer of Chinese garbled problem. Our UTF-8 can solve this problem. ultimately refers to the need to modify the jquery code, the explicit declaration contenttype use Utf-8 character set, you can solve the problem of GB2312 Chinese delivery. 1. Modify the jquery code simply modify the jquery code, plus charset=utf-8, so that you don't need to change what web.config or what is encoded in the page, and you don't need ESCAPC (str) And then decode it on the service side. How to transfer English, how to transfer Chinese. Modify the Used jquery file: jquery-1.4.4.min.js ajaxsettings:{url:location.href,global:true,type: "Get", ContentType: "Application/x-www-form-urlencoded;charset=utf-8", Processdata:true,async:true,xhr:function () { return new E.xmlhttprequest} 2. JS Code: Code is as follows: function Confirmcommit () { var wlcompany = $ ("#wlCompany"). Val ()//Here is the Chinese &N Bsp var wlid = $ ("#wlId"). Val (); var proposer = $ ("#proposer"). Val (); if (confirm) ("Confirm the replacement?") { $.ajax ({ type: ' POST ', URL: ' ${pagecontext.request.contextpath}/returngoods/ Confrimexchangegoods.do ', data: ' wlcompany= ' +wlcompany+ ' &wlid= ' +wlid+ ' &proposer= ' +proposer,//Direct transfer value DataType: ' text ', error:function () { alert ("JQuery AJAX error!"); &N Bsp Success:function (msg) { alert (msg); return; if (msg = = ' Replacement success ', { document.location= ' ${pagecontext.request.contextpath}/orderitem/queryproduceitem.do? Orderbustype= "+${orderbustype}; } } }); &NBSP} } 3. Java code: Code as follows: Public Actionforward confrimexchangegoods (actionmapping mapping, actionform form, HttpServletRequest request, HttpServletResponse response) throws Exception { Log.info ("Confirm replacement Confrimexchangegoods start ........... Response.setcharacterencodinG ("UTF-8"); Here to set the String Wlcompany = Request.getparameter ("Wlcompany"); String wlid = Request.getparameter ("wlid"); String proposer = Request.getparameter ("proposer"); &NBSP ...}