You can get the second element of the list like this:
${partnerList[1].name}
See the freemarker documentation here.
Question
I am doing teplate which i will use in Smooks conversion. I need to get f.e. 2nd element of the list in freemarker but i have no idea how to do it. There is fragment of my code in freemarker template.
<#list partnerList as PARTNER>
${PARTNER.partnrid}
${PARTNER.name}
</#list>
and there is java class:
public class Partner {
private String PARTNRID;
private String NAME;
public String getPartnrid() {
return PARTNRID;
}
public void setPARTNRID(String PARTNRID) {
this.PARTNRID = PARTNRID;
}
public String getName() {
return NAME;
}
public void setNAME(String NAME) {
this.NAME = NAME;
}
}
As i said before i need ONLY 2nd element. I want to avoid printing the rest items. Thanks!
La solution
You can get the second element of the list like this:
${partnerList[1].name}
See the freemarker documentation here.
Autres conseils
You can also obtain the name by writing as shown below
<#list partnerList as PARTNER>
<#if PARTNER.partnrid??>
<partnrid>${PARTNER.partnrid}</partnrid>
</#if>
<name>${PARTNER.name}</name>
</#list>