Display a list in a list with a foreach in jsp

后端 未结 3 1003
一整个雨季
一整个雨季 2021-01-26 00:27

Is it possible to display the elements of a list in a list with a foreach in a jsp?

List> elements;

i was thinking som

3条回答
  •  失恋的感觉
    2021-01-26 00:52

    How would you do it with Java code? You would have two nested loops, right?

    for (List subList : elements) {
        for (String s : subList) {
            System.out.println(s);
        }
    }
    

    You'll need the same thing in your JSP:

    
        
            
        
    
    

    If you know the size of each sublist, then you may get one element (the first, here) using ${subList[0]} :

    
        
    
    

提交回复
热议问题