MySQL stored data garbled problem

Database garbled problem

Recently, garbled characters were found in the data written into the database. I read the method of modifying the my.ini configuration file of MySQL on the Internet, but it didn't work.
insert image description here
Others said to modify the encoding settings of eclipse, but I don't know where this setting is, and I am too lazy to find it.
Then think about whether you can modify the encoding method of the request directly in the program .
So, add this line of code in the class that writes the data or in the JSP

request.setCharacterEncoding("utf-8");

Note that gbk does not work either, it can only be utf-8, probably because the encoding method of MySQL is also utf-8, and there will be no garbled characters when the two correspond.
After adding the above code, save it, restart the Tomcat server, and then write the data, there will be no garbled characters.insert image description here

Guess you like

Origin blog.csdn.net/XiaoLanZi7k7k/article/details/121316830