用英文登录可以显示正常,但用中文登录显示乱码,附件为乱码页面:
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="psdi.util.*, java.net.URLEncoder" %>
<jsp:useBean id="paramBean" scope="request" class="com.actuate.reportcast.utils.ParamHandlerBean" />
<jsp:setProperty name="paramBean" property="request" value="<%= request %>" />
<%
 session.setAttribute("loginPassword2", null);
 String sPassword = paramBean.getParameter("password");
 String spsPassword = sPassword;
 String sUserName = paramBean.getParameter("userName");
 String sUser = paramBean.getParameter("ParmUserName");
 String sPass = paramBean.getParameter("ParmPassword");
 String reportDesc = paramBean.getParameter("reportDesc");
 String directPrint = paramBean.getParameter("PrintAttach");
 String mrolocale = paramBean.getParameter("locale");
 String mroUniqueKey = paramBean.getParameter("mroUniqueKey");
 String attachDirName = paramBean.getParameter("attachDirName");
 
 if (!(sPassword == "" || sPassword == null)) {
   session.setAttribute("loginPassword",sPassword);
   sPassword = sPassword.replaceAll("%", "%25");
   sPassword = CipherPlusBase64.decrypt(sPassword, true);
 } else {
   sPassword = (String) session.getValue("loginPassword");
   sPassword = sPassword.replaceAll("%", "%25");
   sPassword = CipherPlusBase64.decrypt(sPassword, true);
 }
 if (application.getServerInfo().toLowerCase().indexOf("weblogic") > -1)
   sPassword = sPassword.replaceAll("%", "%25");
 // always escape for sps.
 spsPassword = sPassword.replaceAll("%", "%25");
 
 if (!(reportDesc == "" || reportDesc == null)) {
  session.setAttribute("reportDescription",reportDesc);
 } else {
  session.setAttribute("reportDescription","");
 }
 if (!(sUserName == "" || sUserName == null)) {
  session.setAttribute("UserName", sUserName);
 } else {
  session.setAttribute("UserName","");
 }
 if (!(spsPassword == "" || spsPassword == null)) {
  session.setAttribute("Password", spsPassword);
//System.out.println("password-do: " + spsPassword);
 } else {
  session.setAttribute("Password","");
 }
 if (!(directPrint == "" || directPrint == null)) {
  session.setAttribute("PrintAttach", directPrint);
 } else {
  session.setAttribute("PrintAttach","");
 }
 if (!(mrolocale == "" || mrolocale == null)) {
  session.setAttribute("mrolocale", mrolocale);
 } else {
  session.setAttribute("mrolocale","");
 }
 if (!(mroUniqueKey == "" || mroUniqueKey == null)) {
  session.setAttribute("mroUniqueKey", mroUniqueKey);
 } else {
  session.setAttribute("mroUniqueKey","");
 }
 if (!(attachDirName == "" || attachDirName == null)) {
  session.setAttribute("attachDirName", attachDirName);
 } else {
  session.setAttribute("attachDirName","");
 }
%>
<jsp:forward page="/executereport.do" >
 <jsp:param name="password"  value="<%=sPassword%>"/>
 <jsp:param name="jobType"  value="sync"/>
 <jsp:param name="__progressive"  value="True"/>
 <jsp:param name="postback" value="false"/>
 <jsp:param name="invokeSubmit" value="true"/>
 <jsp:param name="doframe" value="true"/>
</jsp:forward> 错误现象:

解决方案 »

  1.   

    一个月??
    不会吧!!jsp乱码不是很复杂啊!!
      

  2.   

    你把你jsp页面开头编码部分 全部改成gbk试试  然后在把你的eclipse的编码也换成gbk 一下编码
      

  3.   

    把开头的第二句<%@ page language="java" pageEncoding="UTF-8"%>
    删了,然后把第一句话的字符集改成gbk
      

  4.   

    这个星期。。我一定痛下。决心。写篇文章。
    关于编码解码:  从jsp -> db 中的过程。怎么转化!页面编码
    服务器编码
    滤器编码
    db 编码大多了!.....每一个设置都有可能影响结果!这个问题提的人太多了。一开始的确让人头痛!
      

  5.   

    我分别采用了几种方式都没办法将表单中的乱码改成中文,我采取的方式有:
    1、添加:<%@ page contentType="text/html; charset=gb2312"%>
    2、类似方法 new String(iso.getBytes("ISO-8859-1"),"GB2312"); 
    3、更改fitler和web.xml
    对了,我用的发布平台是weblogic
      

  6.   

    <%@ page language="java" pageEncoding="UTF-8"%> 这句也更改过 GBK 或 bg2312
      

  7.   

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">另外加上过滤器,并保证数据库也是utf-8
      

  8.   

    数据库, java 和 jsp 所有文件 好像都是utf-8数据库如果不是utf-8 ,怎么转换过来?
      

  9.   

    这个页面有没有经过servlet的处理?如果有,在servlet里配置个字符编码过滤器,就可以了!!!
      

  10.   

    对weblogic不是很熟,肯定是通过了 servlet
    不知道怎么配置
      

  11.   

    http://zhenggm.javaeye.com/blog/606245可以看看这个处理了没有,我很少用weblogic,不过乱码一般处理3个地方,1是客户端浏览器是否始终使用UTF-8发送请求,2是服务器是否始终使用UTF-8编码接收请求,3是用过滤器转换编码。
      

  12.   

    我的数据库的字符集是 ZHS16GBK
      

  13.   

    1、是用utf-8 发送请求
    2、也是
    3、还不清楚
      

  14.   

    不知道LZ解决了没有、
    试试 
    <% response.setCharacterEncoding("GBK")%>
      

  15.   

    resquest.setCharacterEncoding("GBK");这句话放servlet里面接受中文参数
    response相反
      

  16.   

    resquest.setCharacterEncoding("GBK"); 我放在下面这句之前
    <jsp:useBean id="paramBean" scope="request" class="com.actuate.reportcast.utils.ParamHandlerBean" />
      

  17.   

    用了resquest.setCharacterEncoding("GBK"); 之后 英文中文都无法登陆
      

  18.   

    LZ最好将所有编码方式统一起来,别又是UTF-8又是GBK。
    UTF-8和GBK编码方式不一样啊,一个占3字节一个站2字节
      

  19.   


    好的,主要是所有代码都是 UTF-8 数据库确实 GBK16,这个会不会有冲突?
      

  20.   

    会,我遇到过,MYSQL数据库的编码为GBK,存进去的是GBK的时候就显示乱码,,,,可以把数据库的编码改了
      

  21.   

    我在做项目中也会出现乱码,我的做法是URLDecoder和URLEncoder,这样来回转
    不要以为只有URL里面的数据才可以这样
      

  22.   

    LZ你的请求方式好像是GET,你把那GET改成POST应该就没啥问题了,
      

  23.   

    还有,中文千万不要做为参数在url传递
      

  24.   

    url的参数有中文,
    应该在传之前encodeURIComponent(url)一把
      

  25.   

    在顶上加上:<% request.setCharacterEncoding("GBK");%>
    然后将所有的charset=UTF-8改为charset=GBK
      

  26.   

    把所有的都设为utf-8,页面和数据库,就可以简单解决了,
    或者使用过滤器也可以的。
      

  27.   

    String s=new String(request.getparameter(menthod).getbytes("ISO-8859-1"),"GB2312");
      

  28.   

    用这个方法做下转换试试看(DB:ORACLE)。package aa.bb.cc;
    import java.io.*;public class TransFormat {
      // 插入数据库之前使用此方法进行转换
       public static String GBToUnicode(String strIn)
         {
           byte[] b;
           String strOut = null;
           if(strIn == null || (strIn.trim()).equals(""))
             return strIn;
           try
             {
               b = strIn.getBytes("GBK");
               strOut = new String(b,"ISO8859_1");
             }
           catch(UnsupportedEncodingException e)
             {
             }
           return strOut;
         }   // 从数据库取数据库后使用此方法进行转换
       public static String UnicodeToGB(String strIn)
         {
           String strOut = null;
           int strLen = 0;
           strOut = "";       if(strIn == null || (strIn.trim()).equals(""))
             return strIn;
           try
             {
               byte[] b = strIn.getBytes("ISO8859_1");
               strOut = new String(b,"GBK");           // 处理存在半个汉字的情况
               strLen = strOut.length();
               if(strLen == 0)
                 {
                    String tempStr = null;
                    strLen = b.length;
                    tempStr = strIn.substring(0,strLen - 1);
                    byte[] b1 = tempStr.getBytes("ISO8859_1");
                    strOut = new String(b1,"GBK");
                    b1 = null;
                 }
               b = null;
             }
           catch(Exception e)
             {
             }
           return strOut;
         }   // 一般情况下不调用该方法
       // 两种字符集的转换
       public static String ChangeUnicode(String strIn,
         String SourceCode,String TargetCode)
         {
           String strOut = null;
           if(strIn == null || (strIn.trim()).equals(""))
             return strIn;
           try
             {
               byte[] b = strIn.getBytes(SourceCode);
               strOut = new String(b,TargetCode);
             }
           catch(Exception e)
             {
             }
           return strOut;
         }}
    =====
    a.jsp<%
    out.println(UnicodeToGB(request.getparameter(menthod)));
    %>
      

  29.   

    写个javabean,转换成中文。
    不然直接的话,有时候还是不行的
      

  30.   

    修改tomcat配置文件,server.xml 在Connector标签里加上 URIEncoding="UTF-8"如果你在eclipse下启动的tomcat,修改工程Servers下的tomcat-->server.xmlfilter等对get请求不做编码转换。
      

  31.   

    可能有的地方不是UTF_8的编码,你好好看看
      

  32.   

    你的问题没有遇到,我也有很多问题啊
    http://topic.csdn.net/u/20100605/09/d25cbf52-c691-494a-ba95-232a6581ddf1.html?47435
    没人要分吗!!
      

  33.   

    是关于struts2的一个基本实例。
      

  34.   

    在server.xml中的Connectorport添加了URIEncoding="UTF-8",这个方法很管用,楼主试试!对了记得给分哦
    <Connector port="8181" protocol="HTTP/1.1" 
                   maxThreads="150" connectionTimeout="20000" 
                   redirectPort="8443"  URIEncoding="UTF-8"/>
      

  35.   

    再把request获取的值转成GBK就行
      

  36.   

    把那个提交方式改为post提交,就可以了
      

  37.   

    将jsp开头的字符编码方式改为gbk或gb123,其他用到字符编码方式的地方都一起改过来,应该就可以了,我以前编程也遇到这个问题。