前台将参数用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");

 

posted @ 2021-06-11 17:28  薛柏梁  阅读(93)  评论(0编辑  收藏  举报