打印

为什么从数据库中取出的中文都成?号了

JSP+MSSQL+TOMCAT5
做移动WAP页面,从数据库中取出的汉字都变成?号,而直接写的则显示正常,请高手帮忙

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/ wml_1.1.xml">
<%response.setContentType("text/vnd.wap.wml;charset=UTF-8");%>
<%request.setCharacterEncoding("UTF-8");%>
<%response.setHeader("Cache-Control","no-cache");%>
<%@ page pageEncoding="ISO-8859-1"%>

<jsp:useBean id="con" scope="page" class="co.jdbc" />
<jsp:useBean id="vod" scope="page" class="vod.PageCt" />
<%@ page import="java.sql.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.lang.*" %>
<%@ include file="inc/const.jsp" %>
<wml>
<card id="menu" title="<%=con.StringToUnicode("欢迎使用")%>">
<do type="prev" name="Prev" label="Back"><prev/></do>
<p mode="nowrap">
<%
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd");
java.util.Date ds = new java.util.Date() ;
String ddd = formatter.format(ds);
String d1,d2;
d1=ddd+" 00:00:01";
d2=ddd+" 23:59:59";
String infotypeid=request.getParameter("infotypeid").trim();
Connection conn = con.getConn();
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

String sql="select * from info inner join infotype on info.infotypeid=infotype.infotypeid and (createtime between '"+ d1 +"' and '"+ d2 +"') and info.infotypeid="+ infotypeid +" order by id desc";
ResultSet rs=stmt.executeQuery(sql);

rs.next();

long data_num=rs.getLong(1);
long Current_Page = 0;


String currentpage=(String)request.getParameter("currentpage");
if (currentpage != null && !currentpage.equals(""))
{
Current_Page = Integer.parseInt(request.getParameter("currentpage"));
}

String Query_Page=(String)request.getParameter("Query_Page");
if (Query_Page!=null && !Query_Page.equals(""))
{
Current_Page = Integer.parseInt(request.getParameter("Query_Page"))-1;
}

vod.Init(Current_Page,data_num);
long l_start = vod.getStart();
long l_end = vod.getEnd();
%>

<%
long i=0;
while((i<l_start) && rs.next())
{
i++;
}

long j=0,k=(vod.getCurpage())*6;
while(rs.next() && (i<l_end))
{
      k++;
      int cityid;
     if(rs.getInt("cityid")>0)
   {
    cityid=rs.getInt("cityid");
    }
     else
   {
    cityid=0;
    }

     String sql1="select * from city where cityid="+cityid+"";
     ResultSet obj=stmt1.executeQuery(sql1);
     String city="未明";
     while(obj.next())
{
    city=new String(obj.getString("city").getBytes("iso-8859-1"),"gb2312");
   //city=obj.getString("city");
    }

  String url=local_url+"display.jsp?id="+rs.getString("id")+"&page="+page+"&infotypeid="+infotypeid;
     String infotype=new String(rs.getString("infotype").getBytes("iso-8859-1"),"gb2312") ;
  String content=new String(rs.getString("content").getBytes("iso-8859-1"),"gb2312") ;%>
<%=k%>
<a title="<%=con.StringToUnicode("确定")%>" href="<%=url%>">[<%=con.StringToUnicode(rs.getString("infotype"))%>][<%=con.StringToUnicode(city)%>]<%=con.StringToUnicode(content.substring(0,10))%>(<%=formatter.format(rs.getDate("createtime"))%>)</a><br/>
<%
i++;
}
if(vod.getCurpage()>0)
{%>
<a title="<%=con.StringToUnicode("确定")%>" href="<%=local_url%>list.jsp?currentpage=<%=vod.getPrepage()%>&infotypeid=<%=infotypeid%>"><%=con.StringToUnicode("上页")%></a><br/>
<%}%>
<%if(Current_Page<vod.getTotalpage())
{%>
<a title="<%=con.StringToUnicode("确定")%>" href="<%=local_url%>list.jsp?currentpage=<%=vod.getNextpage()%>&infotypeid=<%=infotypeid%>"><%=con.StringToUnicode("下页")%></a><br/>
<%}%>
<br/>
<a title="<%=con.StringToUnicode("确定")%>" href="<%=local_url%>main.jsp"><%=con.StringToUnicode("返回上级")%></a><br/>
<a title="<%=con.StringToUnicode("确定")%>" href="<%=pub_url%>"><%=con.StringToUnicode("返回梦网")%></a><br/>
</p>
<%
try {
              rs.close();
              stmt.close();
              stmt1.close();
              conn.close();
            }
            catch (Exception ex) {
            }
     %>
</card>
</wml>  

------------------------------------
public static String StringToUnicode(String inPara){

  char temChr;

  int ascChr;

  int i;

  String rtStr=new String("");

  if(inPara==null){

   inPara="";

  }

  for(i=0;i<inPara.length();i++){

   temChr=inPara.charAt(i);

   ascChr=temChr+0;

   System.out.println(ascChr);

   System.out.println(Integer.toBinaryString(ascChr));

   rtStr=rtStr+"&#x"+Integer.toHexString(ascChr)+";";

  }

  return rtStr;

}
哈哈哈,,问题已经解决了
加一句<%@ page pageEncoding="GBK"%>就可以了