A detailed analysis of velocity display list and map method _java

Source: Internet
Author: User

I. Traversing a map type

1. First look at the background Java program
Java code

Copy Code code as follows:

Map<string,string> paramvalues=new hashmap<string, string> ();
***
The middle assignment operation omitted the
***
Data.put ("Paramvalues", paramvalues);//pass value to velocity

2. Take out the key and value of this map in the velocity template file of the foreground
Java code
Copy Code code as follows:

#foreach ($param in ${paramvalues.keyset ()})
<tr>
<th> $param </th>
<td>${paramvalues.get ($param)}</td>
</tr>
#end

two. Traverse List Type

1. First look at the background Java code
Java code

Copy Code code as follows:

List<saler> salerlist=new arraylist<saler> ();
***
The middle assignment operation omitted the
***
Data.put ("Salerlist", salerlist);//pass value to velocity

2. See the code in the Velocity template again
Copy Code code as follows:

#foreach ($sal in ${salerlist})
$sal. Name
#end

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.