Common 3 examples and their solutions are as follows
Instance one, when the JSP page is displayed
Run Result:
Workaround: To specify the Chinese character set,
<%@ page contenttype= "text/html;charset=gb2312"%>
Instance two, when the JSP page passes the Chinese parameter
Registration page:
<%@ page contenttype= "text/html;charset=gb2312"%>
Personal Information page:
<%@ page contenttype= "text/html;charset=gb2312"%>
Run Result:
Workaround: Modify the Personal information page as follows
<%@ page contenttype= "text/html;charset=gb2312"%>
Example three, when the servlet handles Chinese parameters
Registration page:
<%@ page contenttype= "text/html;charset=gb2312"%> <%@ page import= "test. Usermsg "%>
Usermsg.java (Servlet)
Package test;
Importjava.io.IOException;
Importjava.io.PrintWriter;
Importjava.io.UnsupportedEncodingException;
Importjavax.servlet.http.HttpServlet;
Importjavax.servlet.http.HttpServletRequest;
Importjavax.servlet.http.HttpServletResponse; Public classusermsg extends httpservlet{public void doget (Httpservletrequestrequest, HttpServletResponse re
Sponse) {doPost (request, response); } public void DoPost (Httpservletrequestrequest, httpservletresponse response) {try {reques
T.setcharacterencoding ("gb2312");
catch (Unsupportedencodingexceptione) {e.printstacktrace ();
} printwriter out = null;
try {out = Response.getwriter ();
catch (IOException E1) {e1.printstacktrace ();
} out.print ("
Run Result:
Workaround: Add in Dopost:
Response.setcontenttype ("text/html; charset=gb2312 ");
The above is a few common JSP Chinese garbled examples and solutions, I hope to help you solve the problem of JSP Chinese garbled.