本帖最后由 zliuzz 于 2009-07-29 14:13:36 编辑

解决方案 »

  1.   

    String div = menuDAO.makeDIV(list);你把div变量转换成utf-8编码jsp加这句
    <%@ page contentType="text/html;charset=UTF-8" %>这样看行不行出现乱码一般的情况都是,在两边的编码格式不统一,造成互相不认识。
      

  2.   

     out.write(div);建议这句换成out.write(div.getBytes("UTF-8"));
      

  3.   

    一般都会乱码,你需要手动编一下码public void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {        
            
            PrintWriter out = response.getWriter();
            int parentId = Integer.parseInt(request.getParameter("pid"));
            MenuDAO menuDAO = new MenuDAO();
            
            response.setContentType("text/html;charset=utf-8");
            response.setCharacterEncoding("utf-8");
            List list = menuDAO.getChildMenu(parentId);
            String div = menuDAO.makeDIV(list);
            div = URLEncoder.encode(div,"utf-8");//讲div编码
            out.write(div);
            out.flush();
            out.close();    }
    var div = xmlHttp.responseText;
    div = decodeURI(div);
    alert(div);楼主试下,好使了别忘了结帖