code020.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>解决中文乱码</title>
</head>
<body>
<%
String str1 = new String(request.getParameter("name").getBytes("iso-8859-1"),"utf-8");
String str2 = request.getParameter("sex"); //没有编码转换的,就是乱码
%>
name参数的值为:<%= str1 %>
sex参数的值为:<%= str2 %>
</body>
</html>