My revision code said, change the current one as it doesn’t follow the principle of "Don't repeat yourself" en.wikipedia.org/wiki/Don%27t_repeat_yourself The if else construct needs to be changed. Technology ".vm", java apach velocity template, but I think this is not very important.
#set($first = "true") #foreach($item in $data) #if($first == "true") <div class="tabs first" id="$item.get('Key')"> #set($first = "false") #else <div class="tabs" id="$item.get('Key')"> #end <h1>str1</h1> <h1>str2</h1> <h1>str3</h1> </div> ##//Close div created in (if else) #end