Recently, when I was working on an SSM framework project, I always encountered a problem, that is, when the backend receives Chinese parameters passed by the front-end, the parameters are garbled, which makes SQL statements often unable to be executed. However, it is very strange that both the test environment and the production environment are normal, but the local development environment is always so tricky, so how to solve it?
1. It’s quite tiring, but if you can’t pass on Chinese, you won’t pass on Chinese parameters. For this point, everyone just smiles. . . .
2. It's still quite tiring. If you really have to pass on Chinese, then you will force the Chinese to transcode, as follows:
"Chinese".getBytes("UTF-8");3. The second point I found this third point before I tried it. As for the second point, if you are interested, you can try it. This third point is the cure. I have been searching for a long time and found that it was a configuration problem of tomcat. Open the conf/server.xml file in the tomcat directory and find the following code part in the file:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/>
Then please add a sentence to configure URIEncoding="UTF-8", as follows:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
It was solved perfectly here, and Benbao's problem was also solved. Momo no longer worried about my sad mood. .
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.