日期:2014-05-18  浏览次数:20642 次

这个问题有点搞笑,大家帮我看看

request.setCharacterEncoding( "gb2312 ");
//设置输出信息的格式及字符集                
                response.setContentType( "text/xml;   charset=gb2312 ");
                response.setHeader( "Cache-Control ",   "no-cache ");
                response.setCharacterEncoding( "gb2312 ");
PrintWriter   out;
out=response.getWriter();
String   cName= " ";
cName=request.getParameter( "categoryName ");
try
{
DataBase   db=new   DataBase();
String   m_SQL=   "INSERT   INTO   categorys   (CategoryName)   values   ( ' ";
 
        m_SQL   =m_SQL   +cName   +   " ') ";
     
db.executeInsert(m_SQL);
out.println( " <response> ");
out.println( " <res> "   +   "添加成功! "+   " </res> ");
out.println( " </response> ");

}
catch   (Exception   ex)
{
out.println(ex.toString());

}

ajax错误,说是页面错误

如果把这句

out.println( " <res> "   +   "添加成功! "+   " </res> ");

换成

out.println( " <res> "   +   "ok   good! "+   " </res> ");

就没问题,也就是说不能返回中文

大家快帮我看看



------解决方案--------------------
out.println( " <?xml version= '1.0 ' encoding= 'gb2312 '?> ");
out.println( " <response> ");
out.println( " <res> " + "添加成功! "+ " </res> ");
out.println( " </response> ");