简体   繁体   中英

Using Java Set in FreeMarker

From my Java code I am returning Set of Address class objects... Now in FreeMarker I want to display the value of all this Address class objects values..

My Java Class

public class Address  implements java.io.Serializable {
private String phone;
private String landLineNumber;

  public Address() {}

  public String getPhone() {
    return this.phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getLandLineNumber() {
    return this.landLineNumber;
  }

  public void setLandLineNumber(String landLineNumber) {
    this.landLineNumber = landLineNumber;
  }

in FreeMarker I am doing following

[#list addList as ${setaddress!''} Phone : ${addList.phone!''}<br/>
Land Line : ${addList.landLineNumber!''}
[/#list]

Now I am getting the error while populating so is it the correct way???

Have you copy-pasted your template properly here? Because it looks weird. It should be something like:

[#list addList as add]
  ${setaddress!''} Phone : ${add.phone!''}<br/>
  Land Line : ${add.landLineNumber!''}
[/#list]

Also, if you don't get any meaningful error message, just a FileNotFoundError , something is wrong with the integration of FreeMarker there...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM