Workaround One:
Javascript:
window.self.location= "searchbytext.action?searchtext=" +encodeuricomponent (encodeURIComponent (Seartext));
Java:
Searchtext=java.net.urldecoder.decode (SearchText, "UTF-8");
Why to encode two times:
Background Java code directly request.getparameter ("ProjectName") is garbled, has not yet called Urldecoder.decode.
Find information when calling Request.getparameter, Java automatically decodes word once, so it is garbled. Now that Java automatically decodes word, we encode it 2 times in the foreground and then backstage
Urldecoder.decode (Request.getparameter ("ProjectName"), "Utf-8″" can solve the problem of garbled.
Workaround Two:
Another way is to encode JavaScript once, the background Java processing when a different idea is good:
Java code:
string s = new string (Request.getparameter ("name"). GetBytes ("Iso8859-1"), "UTF-8");
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
encodeURIComponent code after the Java background decoding garbled solution