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

jsp乱码问题,两个页面晕死
test1.jsp

<%@   page   contentType= "text/html;   charset=gb2312 "   %>
<html>
        <head>
        <title> 个人主页 </title>
        </head>
        <body>
<h1> 乱码 </h1>  
<form   name=form1   method=post   action= " ">
    <input   type=text   name=boy>
    <input   type=submit   value= "提交 "   name=submit>
</form>  
      </body>
</html>

若第1行编码改为utf-8的话,中文显示正常


test2.jsp

<%@   page   contentType= "text/html;   charset=gbk "   %>

<html>
<head> <title> 测试页面 </title>
</head>

<body>
<h1> 测试 </h1>
<form   name=fm   action= 'process.jsp '   method=post>
    <input   type=text   name=boy   >
    <input   type=submit   name=submit   value= "提交 ">
</form>
</body>
</html>

若编码改为utf-8,显示乱码

太郁闷了哦,咋回事呢

------解决方案--------------------
http://my.opera.com/primates/blog/show.dml/118744?0&show=login

http://blog.csdn.net/junye/archive/2005/08/24/464272.aspx
------解决方案--------------------
在工具栏中的window里的属性选项里的General中的Editor里的TextFile coding设为UTF-8
------解决方案--------------------
我猜测你以上页面的代码是在Eclipse中输入的,而且文件的保存编码格式为Unicode形式,之所以显示乱码,是因为,在unicode 模式下的中文 ,在 GBK中根本就不是中文,不行,你虽然 是乱码 ,你更改页面的编码方式为UTF-8,那么乱码就会消失
------解决方案--------------------
缓存,呵呵,清一下缓存再试试,同一个编码在同一个web服务器上展现的效果应该都是一样的啊
------解决方案--------------------
你要把数据库也要设成UTF-8格式