1、向数据库插入中文出现乱码
(1)jdbc:mysql://localhost:3306/world?useUnicode=true&characterEncoding=utf8
* 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾,但;在xml中必须用&转义
(2)数据库字符设定为UTF-8
(3)页面字符设定为UTF-8
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
(4) 前后交互(过滤)字符设定为UTF-8,注意get、post等方式访问实现utf-8 方式不同