The problem of Chinese is often encountered in the application.
This will involve character decoding operations, which we often use in the application of New String (Fieldtype.getbytes ("iso-8859-1"), "UTF-8"), and similar methods to decode it. But this way is limited by the specific application environment, often in the application deployment environment changes, will also appear in Chinese garbled.
Here is a workaround that can be used in any application deployment environment. This method is divided into two steps:
1, in the client with Escape (encodeURIComponent (Fieldvalue)) method encoding, for example:
Copy Code code as follows:
Title=escape (encodeURIComponent (title)); This is the function in JS.
Url= "<%=request.getcontextpath ()%>/print/printlist!printtable.action?title=" +title;
2, in the service End with Java.net.URLDecoder.decode (Getrequest () getparameter ("title"), "UTF-8"), to decode.
-----------------------------------------------------------------------------
The garbled problem of SRC in Parent.window.location.href and iframe.
To pass Chinese in these two URL addresses, you must encode and then decode.
Encoding: encodeURI (encodeURI ("contains Chinese strings")
Decoding: Java.net.URLDecoder.decode ("strings to be decoded", "Utf-8");