ajax| Process | data | issues
These two days are continuing my Ajax journey. have been grasping at the pace.
The day before yesterday to use Ajax to submit form form to the server, get form information content appears garbled, temporarily unable to solve. There is a conclusion on the Internet that is the reason for application/x-www-form-urlencoded coding, I reckon. are looking for a solution to the problem.
Let's discuss the discussion together.
Add: In the background by using UTF8 transcoding method can solve the Chinese garbled problem. This method is submitted for form forms, and the encoding is done on the server. The code is as follows:
FORM.JSP:
<%@ page contenttype= "text/html; charset=gb2312 "%>
form submission Test
<TD width= "height=" > Username:
<TD width= "height=" >
<TR align= "center" >
<TD height= "colspan=" 2 ">
FORM_HANDLE.JSP:
<%@ page contenttype= "text/html; charset=gb2312 "language=" java "errorpage=" "%>
<%
String username = new String (Request.getparameter ("username"). GetBytes ("Iso-8859-1"), "UTF8");
String Password = request.getparameter ("password");
System.out.println ("User name:" +username);
System.out.println ("Password:" +password);
Out.println (username+ "|") +password);
%>
In addition, some netizens react to generate XML documents containing Chinese content to return to the client will also appear garbled problem. It is recommended to change the encoding of XML documents to UTF8 try.