HELLOWROD0123 2022-03-21 09:41 采纳率: 100%
浏览 64
已结题

为什么下面的注册成功界面出现了中文乱码,而注册界面没有乱码

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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">
    <title>用户注册页面</title>
</head>
<body bgcolor="CCCCFF">
<form action="zhucechenggongjiemian.jsp" method="get">
<h2 align="center">欢迎注册Web前端编程学习网站</h2>
<table border="1" width="80%" align="center">
<tr>
    <td>用户名:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
    <td>密码:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
    <td>性别</td>
<td>
    <input type="radio" value="男" name="sex" checked="checked"/><input type="radio" value="女" name="sex"/></td>
</tr>
<tr>
    <td>爱好</td>
<td>
    <input type="checkbox" value="唱歌" name="hobbies"/>唱歌
    <input type="checkbox" value="跳舞" name="hobbies"
    checked="checked"/>跳舞
    <input type="checkbox" value="运动" name="hobbies"/>运动
    <input type="checkbox" value="阅读" name="hobbies"
    checked="checked"/>阅读
</td>
</tr>
<tr>
<td>学历</td>
<td>
<select name="education">
<option value="初中">初中</option>
<option value="高中"selected="selected">高中</option>
<option value="大学">大学</option>
<option value="研究生">研究生</option>
</select>
</td>
</tr>
<tr>
<td>备注说明</td>
<td><textarea name="remark" cols="36"rows="3"></textarea></td>
</tr>
<tr>
<td colspan="2"align="center">
<button type="submit">注册</button>
<button type="reset">清空</button>
        </td>
      </tr>
    </table>
</form>
</body>
</html>


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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">
<title>注册成功页面</title>
</head>
<body bgcolor="CCCCFF" >
<h2>注册成功啦,恭喜!!!</h2>
<%
request.setCharacterEncoding("utf-8");
String username = request.getParameter("username"); 
String password = request.getParameter("password"); 
String sex = request.getParameter("sex");
String remark = request.getParameter("remark");
String education = request.getParameter("education"); 
String[] hobbies = request.getParameterValues("hobbies");
%>
用户名: <%=username %><br>
密码: <%=password%><br>
性别: <%=sex%><br>
<% out.println("爱好: ");
 
   for(int i=0;i<hobbies.length;i++)
  {
    out.println(hobbies[i]+"&nbsp;");
}
%><br>
学历: <%=education%><br>
备注说明: <%=remark%><br>
</body>
</html>


  • 写回答

4条回答 默认 最新

  • CSDN专家-sinJack 2022-03-21 10:00
    关注

    中文乱码是返回的内容乱码,还是页面的中文标题乱码。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 3月29日
  • 已采纳回答 3月21日
  • 创建了问题 3月21日

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来