废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!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数据,希望对大家有所帮助。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“jQuery form插件的使用之处理server返回的JSON, XML,HTML数据”评论...