富贵资源网 Design By www.hznty.com
废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>jQuery form插件的使用--处理server返回的JSON, XML,HTML数据</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="/UploadFiles/2021-04-02/jquery-1.3.1.js">新建json.jsp文件:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8");//防止乱码! String name = request.getParameter("name"); String address = request.getParameter("address"); String comment = request.getParameter("comment"); System.out.println(name + " - " +address + " - " +comment); out.println( "{ name : '" +name+ "' , address : '"+address+ "' ,comment : '"+comment+ "' }" ); %>新建xml.jsp文件:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8");//防止乱码! String name = request.getParameter("xmlname"); String address = request.getParameter("xmladdress"); String comment = request.getParameter("xmlcomment"); System.out.println(name + " - " +address + " - " +comment); response.setContentType("text/xml");//注意,由于你是以xml形式传递过来的,所以这里必须写。 out.print("<"1.0\" encoding=\"UTF-8\""); out.print("<root>"); out.print("<name>"+name+"</name>"); out.print("<address>"+address+"</address>"); out.print("<comment>"+comment+"</comment>"); out.print("</root>"); %>新建一个html.jsp文件:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8");//防止乱码! String name = request.getParameter("htmlname"); String address = request.getParameter("htmladdress"); String comment = request.getParameter("htmlcomment"); System.out.println(name + " - " +address + " - " +comment); out.println( "<div style='background-color:#ffa; padding:20px'>"+name+" "+address+" "+comment+"</div>" ); %>以上所述是小编给大家分享的jQuery form插件的使用之处理server返回的JSON, XML,HTML数据,希望对大家有所帮助。
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...