<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
- contentType: <%@ page contentType=“text/html; charset=UTF-8”%>
web页面显示编码:jsp的输出流在浏览器中显示的编码 - pageEncoding:<%@ page pageEncoding=“UTF-8”%>
jsp页面编码:jsp文件本身的编码 - <META http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
web页面输入编码: 输入框输入的字体编码 - request.setCharacterEncoding("UTF-8"); 对每一个提交的数据都进行编码和解码处理
- response.setCharacterEncoding("utf-8");返回中文的响应
- 3个阶段:输入时的编码,显示时的编码,输出时的编码