ssm框架从前端传值到后台出现乱码的解决办法,你遇到的可能就是这几种

今天遇到的乱码问题让我找了很多地方,现在大致整理一下,

1.Tomcat服务器配置的问题(我今天遇到的就是这个原因),这个是从前端传值到后台乱码,从后台插入到服务器也乱码。

方法:找到Tomcat的安装目录,在cunf下的server.xml文件中找到

<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
<!-- A "Connector" using the shared thread pool-->
把加粗部分的这条语句加上就好了。

2.检查这句话有没有问题db.url=jdbc:mysql://127.0.0.1:3306/myssm?useUnicode=true&characterEncoding=utf8,可以试着把加粗部分不要试下有没有乱码

3.检查前端页面是否有utf-8

4.检查MyEclipse的编码和项目的编码格式是不是一样的。

5.检查数据库的编码格式

另外可以用下面这条转码语句

String educationalLevel = new String(stu.getEducationalLevel().getBytes("ISO8859-1"),"utf-8");

原文地址:https://www.cnblogs.com/la634/p/10575343.html