随笔-0  评论-1  文章-7  trackbacks-0
  • 向server传值
JS:
url = "http://...do?para=" + encodeURI(encodeURI("中文"));//此处要编码两次!
xmlHTTP.open("POST",url,true);
Action:
String para = request.getParameter("para");
para = java.net.URLDecoder.decode(para, "UTF-8");
  • 向client写回
 public static void writeStringToClient(HttpServletResponse response,
   String strMsg) {
  response.setContentType("text/html; charset=utf-8");
  try {
   response.getWriter().print(strMsg);
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
用JS写了一个类似google searchBar的搜索条,就是因为这个问题困扰了半天
posted on 2008-11-25 13:01 adrian615 阅读(146) 评论(0)  编辑  收藏 所属分类: ajax

只有注册用户登录后才能发表评论。


网站导航: