标签归档: jquery Page 1 of 3
JQUERY记录:UI使用和cookie插件
jQuery记录:UI使用和cookie插件.
JQUERY和XML
JQUERY.AJAX访问XML的问题.
不是直接.ajax访问.XML后缀的文件,而是访问对数据进行简单的封装了的xml字符串(对于一般复杂结构数据的传输,像查询出的记录)~比如我下面这段用dom4j生成的XML字符串。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | Response.setContentType("text/html;charset=UTF-8"); PrintWriter writer = Response.getWriter(); String PK_ID = Request.getParameter("selectxmmc"); Connection connection = null; PreparedStatement statementQuery = null; Document doc = DocumentHelper.createDocument(); try { connection = DatabaseHelper.getConnection(componentManager); statementQuery = connection .prepareStatement("select * from oa_sdsl_ss_xm where PK_ID = ?"); statementQuery.setString(1, PK_ID); ResultSet rs = statementQuery.executeQuery(); Element root = doc.addElement("root"); while (rs.next()) { Element xm = root.addElement("xm"); Element dd = xm.addElement("dd"); dd.addText(rs.getString("xmdd")); Element xmfr = xm.addElement("xmfr"); xmfr.addText(rs.getString("xmfr")); Element jsdw = xm.addElement("jsdw"); jsdw.addText(rs.getString("jsdw")); } rs.close(); statementQuery.close(); statementQuery = null; connection.commit(); connection.close(); connection = null; writer.print(doc.asXML()); writer.close(); } catch (Exception ex) { ex.printStackTrace(); writer.print("error"); writer.close(); } finally { if (statementQuery != null) { try { statementQuery.close(); } catch (SQLException ex) { ex.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (SQLException ex) { ex.printStackTrace(); } } } |