Did n years of Java development has never written a website, recently scrambled to get an entrepreneur propaganda website.
As everyone encountered the Chinese character set garbled problem, in order to be able to take some detours less, so here to share a simple and practical solution.
1. POST Data transfer
Receive page
Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
Request.setcharacterencoding ("UTF-8");
String zh_value=reqeust.getparameter ("Zh_value");
%>
The important places are the following two
Copy Code code as follows:
pageencoding= "UTF-8"//declaring the character set of the current page
Copy Code code as follows:
Request.setcharacterencoding ("UTF-8"); Declaring a request's character set
2. Get Data delivery
Receive page
Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
String Zh_value=new string (Request.getparameter ("Zh_value"). GetBytes ("Iso-8859-1"), "UTF-8")
%>
The important places are the following two
Copy Code code as follows:
pageencoding= "UTF-8"//declaring the character set of the current page
Copy Code code as follows:
New String (Request.getparameter ("Zh_value"). GetBytes ("Iso-8859-1"), "UTF-8")// Decodes the acquired string into a byte array based on the iso-8859-1 and then generates a byte array based on the UTF-8 string
If you use the above method can not solve the problem, please be sure to give me a message, I can add more methods to go in for your reference.