mysql中jsp中文乱码怎么解决?干货来了!一定要收藏

很多小伙伴想知道mysql中jsp出现中文乱码的情况该如何解决?那么今天小编就通过这篇文章来给大家分享一个完美解决的方案,如果大家感兴趣的话可以收藏此文章以便下次再次查阅 。

mysql中jsp中文乱码怎么解决?干货来了!一定要收藏

文章插图
JSP页面传输到MySQL数据库时,中文为乱码(数据库中存储乱码)解决方法:
将所有的涉及到编码的都设置为utf-8即可 。
执行mysql> show variables like 'character%';命令查看mysql使用的编码方式:
mysql> show variables like 'character%';+--------------------------+------------------------------------------------------+| Variable_name            | Value                                                |+--------------------------+------------------------------------------------------+| character_set_client     | utf8                                                 || character_set_connection | utf8                                                 || character_set_database   | utf8                                                 || character_set_filesystem | binary                                               || character_set_results    | utf8                                                 || character_set_server     | latin1                                               || character_set_system     | utf8                                                 || character_sets_dir       | D:Program Filesmysql-5.6.20-winx64sharecharsets |+--------------------------+------------------------------------------------------+修改数据库编码执行命令: mysql> alter database db_name character set utf8; 
修改其他编码: mysql> set names 'utf8';

推荐阅读