为了账号安全,请及时绑定邮箱和手机立即绑定

请求转发,转过去用汉语怎么办?怎么转乱码?

请求转发,转过去用汉语怎么办?怎么转乱码?

yanmoer 2016-05-16 16:30:28
一·regist.jsp<%@ 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>Insert title here</title></head><body> <h1>response</h1>   <hr>     <form action="response.jsp" method="post" name="registform">      <ul>       <li>        <label for="">账号:</label>        <input type="text" name="username" id="username" placeholder="输入手机号或其他账号">       </li>       <li>        <label for="">手机号码:</label>        <input type="text" name="phone" placeholder="输入手机号">       </li>       <li>        <input type="submit" id="validation-regist" value="确认注册"/>             </li>      </ul>     </form>     <br></body></html>二·response.jsp<%@page import="jdk.nashorn.internal.runtime.regexp.joni.Regex"%><%@page import="java.io.*"%><%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>        <%         request.getRequestDispatcher("request.jsp").forward(request,response);    %>三·request.jsp<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body> <h1>request内置对象</h1> <%  request.setCharacterEncoding("utf-8");//提交表单汉语变为乱码解决,但无法解决URL传参中文出现乱码  request.setAttribute("password", "123456"); %> 账号:<% String strPtname=request.getParameter("username"); strPtname = new String(strPtname.getBytes("ISO-8859-1"), "UTF-8"); %><%=strPtname %> 手机号:<%=request.getParameter("phone") %>  <br> 密码:<%=request.getAttribute("password") %><br> 请求体的MIME类型:<%=request.getContentType() %><br> 协议类型及版本号:<%=request.getProtocol() %><br> 服务器主机名:<%=request.getServerName() %><br> 服务器对应端口号:<%=request.getServerPort() %><br> 请求文件的长度:<%=request.getContentLength() %><br> 请求客户端的IP地址:<%=request.getRemoteAddr() %><br> 请求的真实路径:<%=request.getRealPath("request.jsp") %><br> 返回上下文路径:<%=request.getContextPath() %><br></body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 4712 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信