url json string parameters and pass a background process [I]

 

When a request url parameter passing to the background, if the parameter is a sequence of objects into json pass, being given directly transmitted, may be transcoded with the json [encodeURIComponent the special symbols {}, etc.] and then transferred transcoding, java background basic need special treatment.

js Go to page:

window.location.href = ctxPath + '/order/custOperate!toAddCust.action?custJson=' + encodeURIComponent(JSON2.stringify(custObj))

 

java Background Processing Analysis:

package com.test;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

public class Json1 {

    public static void main(String[] args) {

//        String reqJson = _request.getParameter("reqJson");
        String reqJson = "{\" idExpDate \ ": \" 2099-12-31 \ ", \" partyName \ ": \" Hua Xia Bank Co., Ltd. \ ", \" partyNumber \ ": \" BJ2018122110041065 \ ", \ "identityType \": \ "2 \", \ "custTree \": {\ "custTreeTopNodeCode \": \ "100207 \", \ "controlArea \": \ "\", \ "controlAreaTop \": \ "\ ", \" custTreeTopName \ ": \" Hua Xia Bank Co., Ltd. \ ", \" custTreeNodeCode \ ": \" 100207 \ ", \" controlDepTop \ ": \" 13007005 \ ", \" controlTypeTop \ ": \" 13013001 \ ", \" controlType \ ": \" 13013001 \ ", \" custTreeName \ ": \" Hua Xia Bank Co., Ltd. \ ", \" controlDep \ ": \" 13007005 \ "}, \" orgUscc \ " : \ "9111000010112001XW \", \ "partyCert \": [{\ "certNum \":\"qazwsxed3\",\"certType\":\"\",\"partyCertId\":\"259941363\"},{\"certNum\":\"9111000010112001XW\",\"certType\":\"49\",\"partyCertId\":\"820108430\"}],\"industryCd\":\"DD0302\",\"isAvailable\":\"1\",\"idEffDate\":\"1992-10-14\",\"industryTypeId\":\"177\",\"orgStatusCd\":\"4\",\"partyId\":\"259941363\",\"registerAddr\":\"北京市东城区建国门内大街22号\"}"\"industryCd\":\"DD0302\",\"isAvailable\":\"1\",\"idEffDate\":\"1992-10-14\",\"industryTypeId\":\"177\",\"orgStatusCd\":\"4\",\"partyId\":\"259941363\",\"registerAddr\":\"北京市东城区建国门内大街22号\"}"\"industryCd\":\"DD0302\",\"isAvailable\":\"1\",\"idEffDate\":\"1992-10-14\",\"industryTypeId\":\"177\",\"orgStatusCd\":\"4\",\"partyId\":\"259941363\",\"registerAddr\":\"北京市东城区建国门内大街22号\"}";
        JSONObject jsonData = JSONObject.parseObject(reqJson);
        String partyName = String.valueOf(jsonData.get("partyName"));
        List<Map<String, String>> partyCertList = (List<Map<String, String>>) jsonData.get("partyCert");
        for (int i = 0; i < partyCertList.size(); i++) {
            Map partyCertMap = partyCertList.get(i);
            System.out.println(partyCertMap);
        }
    }
}

/*

{
    "idExpDate": "2099-12-31",
    "partyName": "Huaxia Bank Co., Ltd. "
    "partyNumber": "BJ2018122110041065", 
    "IdentityType": "2", 
    "custTree": { 
        "custTreeTopNodeCode": "100 207", 
        "the ControlArea": "", 
        "controlAreaTop": "", 
        "custTreeTopName": "China Bank Co., Ltd. ", 
        " custTreeNodeCode ":" 100 207 ", 
        " controlDepTop ":" 13,007,005 ", 
        " controlTypeTop ":" 13,013,001 ", 
        " controlType ":" 13,013,001 ", 
        " custTreeName ":" Hua Xia Bank Co., Ltd. ", 
        " controlDep ":" 13,007,005 " 
    },
    "orgUscc": "9111000010112001XW",
    "partyCert": [
        {
            "certNum": "qazwsxed3",
            "certType": "",
            "partyCertId": "259941363"
        },
        {
            "certNum": "9111000010112001XW",
            "certType": "49",
            "partyCertId": "820108430"
        }
    ],
    "industryCd": "DD0302",
    "isAvailable": "1",
    "idEffDate": "1992-10-14",
    "industryTypeId": "177",
    "orgStatusCd": "4",
    "partyId": "259941363",
    "registerAddr": "北京市东城区建国门内大街22号"
}


*/

 

Guess you like

Origin www.cnblogs.com/libin6505/p/12144338.html