A simple solution to the JSP page to pass the value Chinese garbled

Source: Internet
Author: User

Source code, a.jsp to b.jsp value:

a.jsp Page Content:

<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<form action="b.jsp">
  name:<input type=text name=name>
  <input type=submit>
</form>

b.jsp Page Content:

<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
String name=request.getParameter("name");
%>
<body>
  <%=name%>
</body>

Phenomenon: Chinese garbled, such as "?????? ”

The workaround is as follows:

Method One:

1. In b.jsp, replace pageencoding= "GB2312" with pageencoding= "Iso8859-1"

Although this b.jsp page display content or garbled, but not the kind of "?????? "The garbled, but some special characters

2. Then in the browser to see the menu modified into GB2312 code, then garbled display in Chinese.

3. However, this method is not feasible.

Method Two:

1. In the b.jsp string name=request.getparameter ("name");

String Name=new string (Request.getparameter ("name"). GetBytes ("Iso-8859-1"), "GB2312");

2. Then the display on the page, it is Chinese.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.