学习ajax验证表单时候中文乱码的问题

anltech 2006-05-26 10:51:35
在学习ajax验证的时候:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();

boolean passed = validateUseName(request.getParameter("usename"));
response.setContentType("text/xml;;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
String message = "不可使用的用户名";

if (passed) {
message = "可使用的用户名";
}
out.println("<response>");
out.println("<passed>" + Boolean.toString(passed) + "</passed>");
out.println("<message>" + message + "</message>");
out.println("</response>");
out.close();
}

在页面显示为乱码,请问如何显示正常的中文?谢谢
...全文
179 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuph3000 2006-05-27
  • 打赏
  • 举报
回复
utf-8改gb2312
BuKeQi 2006-05-27
  • 打赏
  • 举报
回复
用utf-8

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧