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


设置JSP页面编码:在页面顶部添加:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>修改数据库连接DriverManager.getConnection(url, usr, pwd)的url:
String url = "jdbc:mysql://localhost:3306/db_name?useUnicode=true&characterEncoding=utf-8";在发送页面和接收页面顶部都添加以下代码:
 <%  request.setCharacterEncoding("UTF-8");  response.setCharacterEncoding("UTF-8");     response.setContentType("text/html; charset=utf-8");%>【mysql中jsp中文乱码怎么解决?干货来了!一定要收藏】以上就是小编给大家带来的在mysql中jsp出现中文乱码的解决方法了,希望大家通过阅读小编的文章之后能够有所收获!如果大家觉得小编的文章不错的话,可以多多分享给有需要的人 。

猜你喜欢