你传过来的字符不是utf-8的把。

解决方案 »

  1.   

    我在做项目的时候也遇到过,将中文作为参数通过http的方式传递,返回到页面就变成了乱码。
    我做的项目是struts+spring+hibernate架构的,所以可以把参数作为FormBean的属性进行传递,就不会出现乱码了。
      

  2.   

    如果是url参数,那需要编写过滤器,你还是使用属性传递吧,这样可能方便些。
      

  3.   

    在接收传递里用setCharacterEncoding("GBK")这个方法
      

  4.   

    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlHttp.responseXML.getElementsByTagName("DISC_ID")[i].firstChild.data);得到的中文数据是乱码
      

  5.   

    在JSP SCRIPT中
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlHttp.responseXML.getElementsByTagName("DISC_ID")[i].firstChild.data);得到的中文数据是乱码
      

  6.   

    如果你用struts可以参考一下
    jsp:
       <head>
        
        <title><bean:message key="statusercompose.application.title" bundle="statusercompose"/></title>
    <%
    request.setCharacterEncoding("UTF-8"); // 系统的环境变量
    String path = request.getContextPath();
       String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
       String servletPath = request.getServletPath();
      
    %>


    <script type="text/javascript">

    var rootUrl="<%=basePath%>";

    //
    var GEId = function(eID) {
    return document.getElementById(eID);
    }


    //
    function check_form(){
    var issueNo=GEId("_issueNo").value;
    if (issueNo==""){
    alert("请输入期号!");
    GEId("_issueNo").focus();
    }else{

    var showType=GEId("showType").value;
    var province=GEId("__province").value;
    var city=GEId("__city").value;
    var county=GEId("__county").value;
    GEId("proCode").value=province;
    GEId("cityCode").value=city;
    GEId("countyCode").value=county;

    if (showType==0){
    document.forms[0].action="<%=basePath%>/statUserCompose.do?method=getStatUserCompose_Table";
    document.forms[0].submit();
    }else{
    document.forms[0].action="<%=basePath%>/statUserCompose.do?method=getStatUserCompose_Chart";
    document.forms[0].submit();
    }

    }
    }


    </script>


    </head>
      <html:form styleId="form1" action="/statUserCompose" method="post">
      <input type="hidden" name="pressCode">
      <input type="hidden" name="pressName">
      </html:form>
    <input type="button" class="bt-2ch" name="b_query" value="查询" onClick="check_form();"> 
    注:pressName是中文,我要把它传到后台做处理;用http参数的方式和用加过滤器的方式得到的结果都是乱码
    通过用js以表单提交的方式进行处理,就不会出现乱码
      

  7.   

    后台:
    /*以表格的方式显示*/
    public ActionForward getUserCompose_Table(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws WebException{

    sucForm = (StatUserComposeForm) form;// TODO Auto-generated method stub

    String validYear=sucForm.getValidYear();
    String pressCode=sucForm.getPressCode();
    String pressName=sucForm.getPressName();
    String districtCode=sucForm.getDistrictCode();
    String serviceId=sucForm.getServiceId();
    String readerClass=sucForm.getReaderClass();

    String issueNo=sucForm.getIssueNo();
    String proName=sucForm.getProName();
    String cityName=sucForm.getCityName();
    String countyName=sucForm.getCountyName();


    service = (IStatUserComposeService) this.getService();

    sucForm.setValidYear(validYear);
    sucForm.setPressCode(pressCode);
    sucForm.setPressName(pressName);
    sucForm.setServiceId(serviceId);
    sucForm.setIssueNo(issueNo);
    sucForm.setProName(proName);
    sucForm.setCityName(cityName);
    sucForm.setCountyName(countyName);
    sucForm.setDistrictCode(districtCode);

    request.setAttribute("sucForm", sucForm);

    List<?> totalList=null;


    addMessage("message.common","发行量趋势分析检索完毕!");
    //设置查询后的结果集
    request.setAttribute("result",totalList);
    return mapping.findForward("table");
    }变量pressName得到正确结果