"Go" velocity shows the list and map methods

Source: Internet
Author: User

One. Traverse a map type

1. Read the background Java program first
Java code


Map<String,string>Paramvalues=New HashMap<string, string>();
***
* * * the intermediate assignment operation omitted
***
Data.put ("paramvalues", paramvalues); pass the value to velocity



2. Remove the key and value of this map from the foreground velocity template file
Java code

#foreach ($param in ${paramvalues.keyset ()})
<Tr>
<th> $param </th>< Span style= "color: #000000;" >  
        <td></td>   
   </tr>&NBSP;&NBSP;
     #end   


Two. Traversing the list type

1. Read the background Java code First
Java code

List<Saler>Salerlist=new arraylist< Span style= "color: #000000;" ><saler> ();   
    ***   
    *** Middle assignment operation omitted   
    ***   
    data.put ( Salerlist "



2. See the code in the Velocity template again

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

Transferred from: http://www.cnblogs.com/likwo/archive/2010/11/25/1887964.html

"Go" velocity shows the list and map methods

Related Article

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.