The third application example of velocity - traversing collections/arrays

黄舟
Release: 2023-03-04 21:24:02
Original
1483 people have browsed it

The third application example of velocity--traversing collections/arrays

//2.Create a Context object
VelocityContext context = newVelocityContext();
//3.Add your data objects to this context
context.put("list",Arrays.asList("第一个","第二个","第三个","第四个"));
//4.Choose a template
Template template =Velocity.getTemplate("list.vm");
//5.Merge the template and your data toproduce the output
StringWriter sw = new StringWriter();
template.merge(context, sw);
sw.flush();
System.out.println(sw.toString());
Copy after login

template

#foreach($elementin $list)

$element

#end







======================



#foreach($ein $list)


$e

#end
Copy after login

The above is the third application example of velocity--traversing collections/arrays For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!