JavaWeb------jsp与数据库传送数据中的乱码问题解决方案

1.统一数据库和eclipse默认的编码均为utf-8(eclipse的编码有工作空间的,jsp的也进行相应更改)
2.前端form表单提交到servlet后,servlet第一行写上request.setCharacterEncoding("UTF-8");
3.在数据库的链接后面加上?useUnicode=true&characterEncoding=UTF-8
   例如:jdbc:mysql://localhost:3306/shopping1?useUnicode=true&characterEncoding=UTF-8

猜你喜欢

转载自blog.csdn.net/qq_34082113/article/details/81609346