回 帖 发 新 帖 刷新版面

主题:中文传递参数出现乱码

高手求救:
跳转前的页面程序为:<a href='editDorm_enroll.jsp?dormno=<%=rs.getString(1)%>'>
跳转至的地址栏为http://localhost/wf/jsp/dorm/editDorm_enroll.jsp?dormno=东205
跳转至页面程序为:String dormno = request.getParameter("dormno");
System.out.println("dormno"+dormno);dormno值是乱码:??205.哪位高手帮帮忙,我好急,谢谢!![color=FF0000]红色[/color]

回复列表 (共5个回复)

沙发

跳转前的页面程序为:<a href='editDorm_enroll.jsp?dormno=<%=rs.getString(1)%>'>
跳转至的地址栏为http://localhost/wf/jsp/dorm/editDorm_enroll.jsp?dormno=东205
跳转至页面程序为:String dormno = request.getParameter("dormno");
                  Byte[] b=dormno.getBytes("ISO-8859-1");
                  dormno=new String(b);
                  System.out.println("dormno"+dormno);
试试先!

板凳

你要把
跳转至页面程序为:String dormno = request.getParameter("dormno");
改为:
跳转至页面程序为:String dormno = new String(request.getParameter("dormno").getBytes(8859_1));

3 楼

小弟也遇到同样的问题,上面两楼的方法我知道也试过了,但还是不行,以前...aaa.jsp?action=XX;并没用过中文,所以没有出错过,但最近用到老是不能解决,经过我的测试,用表单提交,的中文以上两楼的方法可行,但如楼主这般却显示为乱码。不知道怎么解决啊。高手门救命啊。

4 楼


<%! String trans(String chi)//trans  用于字符编码的转换
        {
                       String result = null;
                       byte temp [];
                       try
                       {
                               temp=chi.getBytes("iso-8859-1");
                              result = new String(temp);
                        }
                        catch(UnsupportedEncodingException e)
                        {
                                System.out.println (e.toString());
                        }
                    return result;
        }
        %>
        <% 
            //request.setCharacterEncoding("gb2312");
            messageBean mebe=TopDel.getmessage(trans(request.getParameter("title")));
            //    response.sendRedirect("ManChart.jsp");
         %>
试试

5 楼

我已经搞好了,请看下面的程序:

跳转前的页面程序为:<a href='editDorm_enroll.jsp?dormno=<%=rs.getString(1)%>'>
跳转至的地址栏为http://localhost/wf/jsp/dorm/editDorm_enroll.jsp?dormno=东205

你先先看看你的地址栏的参数值是不是乱码,如果不是那就仅需要在跳转至的页面加上这样一句:theCharSet="charset=GB2312";就可以了.如果不行你就把你的整个程序给我看看.我基本知道是什么问题,因为我对这些问题钻研了好久.

我来回复

您尚未登录,请登录后再回复。点此登录或注册