加上这样一句:
<%page contentType="text/html charset=gb2312">
直接打印,可以吗???

解决方案 »

  1.   

    在jsp文件的开始加上:
    <%@ page contentType="text/html;charset=gb2312" %>
    servlet:
    doGet(),doPost()的第一句为:
    res.setContentType("text/html;charset=gb2312"); 以后的情况分别为:
    1. 在servlet/jsp源文件中硬编码的中文,传送到Browser时,不需要转换2. 在servlet/jsp源文件中硬编码的中文,插入到数据库时时,不需要转换
    3. servlet/jsp从数据库检索出的中文,传送到Browser时,不需要转换4. 从Browser端post或get参数传到servlet/jsp的中文,插入数据库时,需要转换为GB2312 
    5. 从Browser端post或get参数传到servlet/jsp的中文,再传回Browser时,需要转换为GB23126. include的情况:
    例:
    b.jsp  (其中include文件a.jsp)
    <%@ page contentType="text/html;charset=gb2312" %>
    <p><%@ include file="a.jsp" %>
    <p>或<jsp:include page="a.jsp" flush="true"/>  a.jsp  (被include的文件)
    <%@ page import = "com.etang.itsd.*" %>
    <%=Language.parseGB("测试中文问题")%>
    <%="aaabbbccc"%>其中类com.etang.itsd.Language和函数String parseGB(String)说明参见后面------------------------------------------------
    package com.etang.itsd;import java.io.UnsupportedEncodingException;public class Language
    {
    //将ISI-8859-1编码的String转化为GB2312编码的String
    public static String parseGB(String in) 

    String s = null; 
    if (in == null) 

    System.out.println("Warn:Chinese null founded!"); 
    return new String(""); 

    try 

    s = new String(in.getBytes("iso-8859-1"),"GB2312");
    return s;

    catch(UnsupportedEncodingException e) 

    System.out.println (e.toString()); 
    return new String(""); 

    }//将GB2312编码的String转化为ISI-8859-1编码的String 
    public static String parseISO(String in) 

    String s = null; 
    if (in == null) 

    System.out.println("Warn:Chinese null founded!"); 
    return new String(""); 

    try 

    s = new String(in.getBytes("GB2312"),"iso-8859-1");
    return s;

    catch(UnsupportedEncodingException e) 

    System.out.println (e.toString()); 
    return new String(""); 

    }} 
      

  2.   

    to icesail:
    sorry,add this line:
    <%@ page contentType="text/html; charset=gb2312"%>
    error is still!
      

  3.   

    中文问题在IBM Websphere 3.5版本中不存在了。是javasoft的基本类库有问题