Joke Collection Website - Public benefit messages - How to deal with the URL of java SMS and how to deal with Chinese garbled code.

How to deal with the URL of java SMS and how to deal with Chinese garbled code.

1, which is coded by the method of escape (field value) at the client, for example:

The copy code code is as follows:

title = escape(encodeURIComponent(title)); //This is a function in js.

url = " & lt% = request . getcontextpath()% & gt; /print/printList! printTable.actiontitle = "+title;

2. On the server side, use java.net.urldecoder.decode (getrequest (). Getparameter ("title"), "UTF-8").

-

The garbled problem of src in parent.window.location.href and iframe.

To transmit Chinese with these two url addresses, it must be encoded first and then decoded.

Code: encodeURI(encodeURI ("string containing Chinese"))

Decoding: java.net.URLDecoder.decode ("string to be decoded", "UTF-8");