How to Loop Through a List of Objects in FreeMarker

104 40
    • 1). Create a new text document by opening a Text Edit program. Save the document as “tutorial.html.”

    • 2). Write an HTML statement that outputs some helpful text that identifies the list of objects:

      <p>Here are the cars we have for sale:
      <ul>

    • 3). Write a FreeMarker directive that accesses the Data Model of the Model View Controller application. For example, if your Data Model has a list of objects named “cars” under the heading “dataModelCars,” you can loop through the entire list by writing the following FreeMarker directive:

      <#list dataModelCars.cars as car>
      <li>${car}
      </#list>
      <ul>

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.