Search code examples
spring-mvcjstl

MongoDB - How to declare object variable in jstl


I'm using MongoDB, My object is like this

{ 
    "id" : "1", 
    "Name" : "jack", 
    "Date" : "22-03-2018", 
    "Time" : "123412", 
    "tmax_volumes" : {
        "type1" : "392.7cm", 
        "type2" : "83.1cm", 
        "type3" : "24.1cm", 
        "type4" : "15.6cm"
    }
}

Now want to print tmax_volumes in my jstl page.

In my jstl page using ${COLL.tmax_volumes} this variable I'm getting tmax_volumes object, like this below

    { 
     "type1" : "392.7cm" , 
     "type2" : "83.1cm" , 
     "type3" : "24.1cm" , 
     "type4" : "15.6cm"
   }

Now I need to pring using Key values,

392.7cm
83.1cm
24.1cm
15.6cm

Thanks


Solution

  • In my model, I map tmax_volume Object

    private Map<String,String> tmax_volumes;
    

    And my jstl page, I have assigned like this below

    <p>${COLL.tmax_volumes.type1}</p>
    <p>${COLL.tmax_volumes.type2}</p>
    <p>${COLL.tmax_volumes.type3}</p>
    <p>${COLL.tmax_volumes.type4}</p>