Solution to the problem of disorderly code in Chinese parameters of hyperlink transfer in JSP page

Time:2020-4-15

In this paper, an example is given to show how to solve the problem of disorderly code in Chinese parameters of hyperlink transfer in JSP pages. To share with you for your reference, as follows:

This paper analyzes how to solve the problem of garbled code in the receiving page.

resolvent:

You can do the following in the accept page,

Copy codeThe code is as follows:
<% = new string (request.getparameter (“variable name”). GetBytes (“iso-8859-1”)% >

Note that new string () is used to create a new string

Example:

Page 1:

<html>
 <head>
  < title > Page 1 < / Title >
 </head>
 <body>
 < a href = "2. JSP? Name = Zhang San & password = 123456" > pay attention here</a>
 </body>
</html>

Page two:

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>
 <head>
  < title > page 2 < / Title >
 </head>
 <body>
  <%=new String(request.getParameter("name").getBytes("ISO-8859-1")) %> &&
  <%=request.getParameter("password") %> 
 </body>
</html>

I hope this article is helpful for JSP programming.