When java accepts get requests sent from the android client, garbled code is used to solve the problem.
This afternoon, I encountered a very common problem. However, after N times, I couldn't find an effective solution, A simple and effective method is developed.The implementation idea is as follows::
(1) Before the android client sends a get requestString str = URLEncode. encode (str, "UTF-8 ");Specify the encoding format as UTF-8 so that android clients send requests to the server in UTF-8 format.
(2) The server obtains the parameter value through request. getParameter ("str. In this way, the obtained parameter values will not be garbled!
Note:(1) str indicates the variable name that needs to be specified in the encoding format.
Gains:Try to prevent Garbled text before sending a request from the client. Otherwise, it will be very difficult for the background to transfer the Garbled text out of Chinese!
Filters in web. xml files are generally used to filter Garbled text in post requests and cannot filter Garbled text in get requests.
Although many problems seem common and simple, they may become the killer of wasting your precious time.