1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. jQuery解析json數(shù)據(jù)實(shí)例分析問(wèn)題

        時(shí)間:2020-11-10 08:34:42 JSON 我要投稿

        jQuery解析json數(shù)據(jù)實(shí)例分析問(wèn)題

          先來(lái)看看我們的Json數(shù)據(jù)格式:

          [{id:01,name:"小白",old:29,sex:"男"},{id:02,name:"小藍(lán)",old:29,sex:"男"},{id:03,name:"小雅",old:29,sex:"男"}]

          為了消除亂碼問(wèn)題,我們?cè)O(shè)置一個(gè)過(guò)濾器(代碼片段)

          public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); chain.doFilter(req, resp);}

          服務(wù)端我用Servlet生成json數(shù)據(jù)(代碼片段)。

          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); //過(guò)濾器已經(jīng)做過(guò)編碼轉(zhuǎn)化了。 resp.setContentType("text/html;charset=UTF-8"); StringBuffer sb = new StringBuffer(); sb.append("[{id:01,name:"小白",old:29,sex:"男"},"); sb.append("{id:02,name:"小藍(lán)",old:29,sex:"男"},"); sb.append("{id:03,name:"小雅",old:29,sex:"男"}]"); out.print(sb);}

          頁(yè)面端JQuery代碼:

          <%@ page="" contenttype="text/html;charset=UTF-8" language="java">

          寫到.jsp、.txt文件中的json數(shù)據(jù),沒(méi)有被解析出來(lái),F(xiàn)irebug中調(diào)試了一下,10行斷點(diǎn)下一步直接結(jié)束,就沒(méi)有遍歷對(duì)象數(shù)組。于是分別測(cè)試了一下文本文件 json.txtjsp文件 json.jspServlet json.do返回的'數(shù)據(jù),瀏覽器只有解析出Servlet的返回的數(shù)據(jù)是json數(shù)據(jù)希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

        【jQuery解析json數(shù)據(jù)實(shí)例分析問(wèn)題】相關(guān)文章:

        1.json實(shí)例解析方法

        2.IOS中Json解析實(shí)例方法詳解

        3.JQuery中serialize()用法實(shí)例分析

        4.json定義及jquery操作

        5.JQuery中Text方法用法實(shí)例分析

        6.Ajax使用JSON數(shù)據(jù)格式案例分析

        7.jQuery中delegate()實(shí)例用法

        8.Json的生成與解析

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>