Solution to the problem of garbled Chinese parameters transmitted by hyperlinks in JSP page
- 2021-09-05 00:39:37
- OfStack
This article describes the example of JSP page hyperlink transfer Chinese parameters appear garbled problem solution. Share it for your reference, as follows:
Here, we analyze the solution to the problem of garbled code in the acceptance page by transmitting Chinese parameters with hyperlinks.
Solution:
You can do the following on the Acceptance page,
<%=new String(request.getParameter(" Variable name ").getBytes("ISO-8859-1")) %>
Note that new String () is used here to create a new string
Example:
Page 1:
<html>
<head>
<title> Page 1</title>
</head>
<body>
<a href="2.jsp?name= Zhang 3&password=123456"> Pay attention to this </a>
</body>
</html>
Page 2:
<%@ 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 to everyone's JSP programming.