It seems strange to get object values from "spring"

时间:2017-05-16 09:26:01

标签: java spring jsp

    obj = {"A":"A","B":"B"};
    $.ajax({
        url : "blur",
        data : {
            "aaa":obj
        },

        type : 'POST',
        success : function(result) {
            console.log("data : ",result);
        },


    });
    @RequestMapping(value="blur.do")
    public ModelAndView aa(@RequestParam HashMap<String, 
    Object>dto) throws Exception {

    ModelAndView mav = new ModelAndView();

    log.debug("********** map: " + dto); 
    // dto.get("aaa") -> error
    // dto.get("aaa[A]") -> A
    return mav;
}


"********** aaa: dto : {aaa[A]="A",aaa[B]="B"}

Like the source above, I passed the value using "ajax".

But it looks like this:

The result I want is {aaa={"A","B")}

1 个答案:

答案 0 :(得分:0)

try this

var obj; 
obj = {"aaa":{"A":"A","B":"B"}};
console.log(obj);
console.log(obj["aaa"]);
console.log(obj["aaa"]["A"]);

output :

Object { zzz: Object, aaa: Object }

Object { A: "A", B: "B" }

A