现在我用jsp编写smtp发信程序,想实现中文发信,但中文全部都是乱码,请问怎么解决这个问题,多谢

解决方案 »

  1.   

    //设置标题以及内容
        
        subject = MimeUtility.encodeText(new String(subject.getBytes(), "GB2312"), "GB2312", "B");
        message.setSubject(subject);     //message.setText(body);
        message.setContent(body,"text/html; charset=gb2312");
      

  2.   

    jsp页面保存到数据库有乱码解决方法Jsp+tomcat+bean中文乱码问题解决方法javabean中参数有乱码
    1) 所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
    2) 在应用服务器中的server.xml方件中找到设置服务器端口的行,一般是这样开头:”<Connector port="8080"”,
    3) 在找到的行"<Connector"开头的字符串后加上:URIEncoding="UTF-8" ,保存文件
    --------------------------------------------------------------------------
    jsp页面有乱码解决方法    所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
        <%@ page contentType="text/html; charset=UTF-8">
    --------------------------------------------------------------------------
    jsp单个中文参数乱码解决方法    用这个转换一下: 
        <%!String trans(String chi)
           {
            string result =null;
            byte temp[];
            temp=chi.getBytes("iso=8859-1");
            result= new String(temp);
            }
        %>
    或者直接这样:
        <% 
          request.setCharacterEncoding("UTF-8");
          out.println(request.getParameter("参数ID")
        %>
    --------------------------------------------------------------------------