This problem has troubled me a long time, and remember to write it down: the future use of ajax, the background of the action with struts to deal with information, and then returned to the client when a Chinese problem, because here the default js file is utf-8 encoding, and the struts , action here, the default encoding is iso-8859-1, so when ajax send a parameter to the server if it is Chinese, into the database will be garbled, the same action in the out.println () information as a Chinese client will also be garbled, the solution is in action (can be a servlet) with URLDecoder.decode (tid, "utf-8"); method decoder, for output to the client's content to read:

response.setContentType ( "text / xml; charset = UTF-8");

response.setContentType ( "text / xml; charset = UTF-8");

PrintWriter out = null; (the order must not be the other way around)

At this time in the mass of the past will not be garbled.

For example, client is I (ajax way to the post)

function deleteBooktypeByTid (tid, row)

(Var flag = confirm ( "\ u786e \ u5b9a \ u8981 \ u5220 \ u9664 \ u56fe \ u4e66 \ u7c7b \ u522b \ u53f7 \ u4e3a \ uff1a" + tid + "\ u7684 \ u56fe \ u4e66 \ u5417 \ uff1f \ n \ u8fd9 \ u4e2a \ u64cd \ u4f5c \ u4f1a \ u5220 \ u9664 \ u8fd9 \ u4e2a \ u7c7b \ u522b \ u7684 \ u6240 \ u6709 \ u56fe \ u4e66 \ u54e6 ");

if (! flag) (return false;)

var tid = tid;

var row = row;

var url = "deleteBooktypeByTid.do";

var postStr = "booktype =" + tid;

postStr = encodeURI (postStr);

postStr = encodeURI (postStr);

(Tens of millions of these two changes have forgotten, if forgotten from the client to the server may be garbled pyronaridine)

var ajax = false;

if (window.XMLHttpRequest)

(Ajax = new XMLHttpRequest ();

if (ajax.overrideMimeType)

(Ajax.overrideMimeType ( "text / xml");)

)

else

(If (window.ActiveXObject)

(Try

(Ajax = new ActiveXObject ( "Msxml2.XMLHTTP");

) Catch (e)

(Try

(

ajax = new ActiveXObject ( "Microsoft.XMLHTTP");

)

catch (e) ())))

if (! ajax) (window.alert ( "err."); return false;)

ajax.open ( "POST", url, true);

ajax.setRequestHeader ( "Content-Type", "application / x-www-form-urlencoded");

ajax.setRequestHeader ( "If-Modified-Since", "0");

ajax.send (postStr);

ajax.onreadystatechange = function ()

(

if (ajax.readyState == 4 & & ajax.status == 200)

(

alert (ajax.responseText);

document.getElementById ( "table_queryBooktype_id"). deleteRow (row);

)

)

) Then alert () out of a garbled message does not matter, unlike the above, then on to do so is likely to appear garbled.