请问高手为什么用JAVA的HTTP递交给JAVAServelet的时候,中文变成乱码了,急教!!!!!!!
为什么用JAVA的HTTP递交给JAVAServelet生成JSP页面的时候,中文变成乱码了,请提供详细方法或源代码,谢谢!!!!!!
------解决方案-------------------- <meta http-equiv= "Content-Type " content= "text/html;charset=UTF-8 ">
<% response.setContentType( "text/html;charset=UTF-8 "); %>
<% response.setCharacterEncoding( "UTF-8 "); %>
让JSP编译器能正确地解码我们的含有中文字符的JSP文件
<%@ page pageEncoding= "UTF-8 "%>
JSP向客户端输出
<%@ page contentType= "text/html;charset=UTF-8 " %>
让JSP能正确获得传入的参数
<% request.setCharacterEncoding( "UTF-8 "); %>
浏览器默认使用 UTF-8 的编码方式发送请求
1、Eclipse
2、MyEclipse
3、JSP
<%@ page contentType= "text/html;charset=UTF-8 " %>
<head>
<meta http-equiv= "Content-Type " content= "text/html;charset=UTF-8 ">
</head>
4、超连接访问
String language = request.getParameter( "language ");
language = new String(language.getBytes( "ISO-8859-1 "), "UTF-8 ");
5、Servlet
request.setCharacterEncoding( "UTF-8 ");
response.setContentType( "text/html;charset=UTF-8 ");
6、AJAX
response.setContentType( "text/xml;charset=UTF-8 ");
------解决方案--------------------凡是涉及到编码问题的地方,都将编码设置为UTF-8或GBK、GB2312