Java's get and post are parsed again

*, java get and post

href is to send a request in the get method
The post method can be requested through the form form or ajax method

 

*, the get method is garbled again

The Chinese garbled solution in the get request is as follows:
value = java.net.URLEncoder.encode(value,"UTF-8");
value = java.net.URLEncoder.encode(value,"UTF-8");
Yes, you read that right, you need to transcode twice
Yes, you read that right, you need to transcode twice
Yes, you read that right, you need to transcode twice
When decoding, the following is required:
value = java.net.URLDecoder.decode(value,"UTF-8");
Of course if you write
value = java.net.URLDecoder.decode(value,"UTF-8");
value = java.net.URLDecoder.decode(value,"UTF-8");
it is also fine! ! !

 

Remark:

When writing java code in jsp, "==" is used to judge whether the strings are equal or not. There is a bug, but because I believe that there is no problem with this judgment method, I always wrongly think that there is a problem with the coding method, and I have taken a lot of detours. Eventually changing to value.equals(temp) found and solved the problem.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326480568&siteId=291194637