MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 这个有关问题有点搞笑,大家帮我看看

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

www.MyException.Cn  网友分享于:2013-11-28  浏览:256次
这个问题有点搞笑,大家帮我看看

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> ");

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有