其他分享
首页 > 其他分享> > 前台将参数用json打包到后台

前台将参数用json打包到后台

作者:互联网

   //前台 代码
   var startDate = $('#startDate').val(); var endDate = $('#endDate').val(); var businessCustomerinvoicecode1 = $('input[name="businessCustomerinvoicecode1"]').val(); var aviation_id = '${aviation_id}'; var mainNumber = '${mainNumber}'; var jsdata = { startDate : startDate, endDate : endDate, businessCustomerinvoicecode1 : businessCustomerinvoicecode1, aviation_id : aviation_id, mainNumber : mainNumber, isbd : 2, } var jsd = JSON.stringify(jsdata); // jsd就是打包的参数
//后台取值

String jsd = request.getParameter("jsd");
        try {   

            JSONObject json = JSONObject.fromObject(jsd);
            String aviation_id = json.getString("aviation_id");
            String mainNumber = json.getString("mainNumber");
            String startDate = json.getString("startDate");
            String endDate = json.getString("endDate"); 
            String isbd = json.getString("isbd"); 
            String businessCustomerinvoicecode1 = json.getString("businessCustomerinvoicecode1");

 

标签:startDate,endDate,String,getString,json,前台,var,打包
来源: https://www.cnblogs.com/xueblvip/p/14875967.html