Chinese parameter garbled solution when get is submitted

The code processed by Java is:

searchtext=java .NET .URLDecoder.decode(searchtext,"UTF-8");/*An exception needs to be handled*/

At first glance, it doesn't seem to be a problem. It should be ok if you compile it one by one. But still garbled.

Later, I searched for information on the Internet and found that when the searchtext in the background java program was assigned, it had already used a decoding, but the decoding result was still wrong. So we can perform two encoding operations on the page, so that the automatic one in the background can be offset once, and then use searchtext=java .Net .URLDecoder.decode(searchtext,"UTF-8");/*Need to be processed Exception */ Just do a decode once.

Correct code:

JavaScript:

window.self.location="searchbytext.action?searchtext="+encodeURIComponent(encodeURIComponent(seartext));

java:

searchtext=java.net.URLDecoder.decode(searchtext,"UTF-8");/*An exception needs to be handled*/

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326837809&siteId=291194637