如果servlet连接数据库,返回的是list类型的数组,jsp页面该怎样解析jsonArry并打印道下面提示框内
() { (.=== ) (.=== ) { =.responseText; = .(); (); } }
doGet(HttpServletRequest request, HttpServletResponse response) ServletException, IOException { request.setCharacterEncoding( ); response.setCharacterEncoding( ); String keyword=request.getParameter( ); ArticleService articleService=ArticleService(); UserService userService = UserService();JSONArray jsonArray = JSONArray(); List<Bbs_litleArt> listData1 = articleService.search_article( keyword ); (Bbs_litleArt bbs_litleArt:listData1) { JSONObject jsonObject = JSONObject( bbs_litleArt ); jsonArray.put( jsonObject ); } System..println(jsonArray); response.getWriter().write(String.(jsonArray)); }