日期:2014-05-18  浏览次数:20656 次

url中文编码问题
在一个页面上
<html> <head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 "   /> </head>
<body>
<form   method= "get "   action=/webchat/sender.cl>
<input   id= "receiver "   name= "receiver "   type= "text "   />
<input   id= "msg "   name= "msg "   type= "text "/> <
input   type= "submit "/>
</form>
</body> </html>
在msg框打上 "输入 "2词的时候,编码会成%26%2336755%3B%26%2320837%3B
在服务器端接受到是&#36755;&#20837;
而在url中将输入的编码改为:%E8%BE%93%E5%85%A5
服务器端则是正确的显示


------解决方案--------------------
<meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 " /> </head>


这个地方错了,编码方式应该是charset=GBK 或者是GB23
------解决方案--------------------
如果你是用TOMCAT服务器的话:把SERVER.XML文件里的: <Connector port= "80 " maxHttpHeaderSize= "8192 "
maxThreads= "150 " minSpareThreads= "25 " maxSpareThreads= "75 "
enableLookups= "false " redirectPort= "8443 " acceptCount= "100 "
connectionTimeout= "20000 " disableUploadTimeout= "true " URIEncoding= "UTF-8 "/>
URIEncoding= "UTF-8 "/这句写成这样
要不把页面的改为
<%@page language= "java " contentType= "text/html; charset=GBK " pageEncoding= "GBK "%>

------解决方案--------------------
<%
String msg=request.getParameter( "msg ");
name=new String(name.getBytes( "ISO8859_1 "),
"gb2312 ");
out.println( "msg: " +name+ " <br> ");
%>

------解决方案--------------------
action里加request.setCharacterEncoding( "utf-8 ");试试