본문 바로가기
공부/java & Spring

[Spring] map value 출력

by 고기 2023. 4. 23.
@GetMapping("/test")
public void test() {
    log.info("info !!");
    Map<String, Object> w = new HashMap<String, Object>();
    Map<String, Object> ww = new HashMap<String, Object>();
    Map<String, Object> www = new HashMap<String, Object>();

    ww.put("equipElement1", "aaa");
    ww.put("equipElement2", "bbb");
    ww.put("equipElement3", "ccc");
    ww.put("equipElement4", "ddd");

    w.put("1", ww);

    www.put("equip1", "eee");
    www.put("equip2", "fff");
    www.put("equip3", "ggg");
    www.put("equip4", "hhh");

    w.put("2", www);

    log.info("www:" + www);
    log.info("www:" + www.toString());

    Map<String, Object> wwww = (HashMap<String, Object>) w.get("1");
    log.info("wwww:" + wwww);

    String wwwww = (String) wwww.get("equipElement1");
    log.info("wwwww:" + wwwww);
}

--- print --- 

2023-04-23 23:42:17.343  INFO 12768 --- [.0.0-443-exec-3] S.mh.controller.characterCardController  : info !!
2023-04-23 23:42:17.345  INFO 12768 --- [.0.0-443-exec-3] S.mh.controller.characterCardController  : www:{equip1=eee, equip2=fff, equip3=ggg, equip4=hhh}
2023-04-23 23:42:17.345  INFO 12768 --- [.0.0-443-exec-3] S.mh.controller.characterCardController  : www:{equip1=eee, equip2=fff, equip3=ggg, equip4=hhh}
2023-04-23 23:42:17.345  INFO 12768 --- [.0.0-443-exec-3] S.mh.controller.characterCardController  : wwww:{equipElement4=ddd, equipElement1=aaa, equipElement2=bbb, equipElement3=ccc}
2023-04-23 23:42:17.345  INFO 12768 --- [.0.0-443-exec-3] S.mh.controller.characterCardController  : wwwww:aaa

 

 

 

댓글