Interaction between JSP page and database Chinese garbled problem

Solution

1. Add the coded character set after the local database address and name:

?useUnicode=true&characterEncoding=UTF-8

Complete as follows:

String url = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8";

2. Add the following statement to the JSP page:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%request.setCharacterEncoding("UTF-8");%> 
 <%response.setContentType("text/html;charset=utf-8");%>
 <meta charset="UTF-8">

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324789264&siteId=291194637
Recommended