Home > Article > Web Front-end > JS alternative method to solve the problem of Chinese garbled characters in url value transfer_javascript skills
When developing web applications, many situations require data interaction between the front and backends. Sometimes we may need to pass the Chinese data in the frontend to the backend through URLs, but at this time there is a headache, because The standard character set used for network transmission in Java is ISO-8859-1, so when you use request.getParameter("message") in the background to get the Chinese sent from the front, you still get the ISO-8859-1 character set, and the Chinese is There will be garbled characters. The solution for many people is to decode before transmitting Chinese in the foreground, and then decode and convert it in the background. This feels very troublesome. Is there no other way to solve it?
I thought hard for a while: Why can the form be used to transmit Chinese, but the URL method cannot be used? Do we have to use URL to pass value to solve the problem? Here I thought of dynamic forms, why not use it to solve the problem, the example is as follows:
Suppose there is the following application scenario: In the KPI list page, each KPI has the function of generating early warning data. When you click the button to generate data for each KPI in the list, the id and name of the KPI need to be passed to the background.
The js method corresponding to the front end:
Use URL to pass value:
}
This can be solved by dynamically generating the form: