Recently learning JSP, and most novice encountered the Chinese display problem, there are two kinds of Chinese problems:
(1) The appearance of the page itself in Chinese, the solution for the JSP page at the beginning of the join
<%@ page language= "java" contenttype= "text/html;charset=gb2312" pageencoding= "GB2312"%>
or <%@ page language= "java" contenttype= "text/html;charset=gb2312"%>
or change the GB2312 above to GBK, so that the Chinese in the JSP page will appear correctly.
(2) The value of the requested parameter in the JSP page is Chinese, the value of Request.getparameter ("AttributeName") is Chinese, so without any setting, the display will have problems, there are two ways to solve the problem.
1 before the appearance of all request.getparameter ("attribute"), add
Request.setcharacterencoding ("GB2312");
or request.setcharacterencoding ("GBK");
2 The second method is to add the following after each string Attributename=request.getparameter ("AttributeName") statement
Attributename=new String (attributename.getbytes ("iso-8859-1"), "GB2312");
or Attributename=new String (attributename.getbytes ("Iso8859_1"), "GB2312");
or Attributename=new String (attributename.getbytes ("iso-8859-1"), "GBK");
PS: A method labeled 1 and 2 cannot be used at the same time, or it will fail at the same time, only one of these methods can be used
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.