简体   繁体   中英

Set list of property in jsp from java class

I have a list of objects like

ArrayList<FieldTo> fieldsList;

and FieldTo has

private long fieldId;

private String category;

private Organization organization; ... etc with getter and setter

How can i set this fieldId , category , etc as property in jsp.

Please mention in detail, you are explaining to a fresher in struts

Note: Iam using table in jsp to set these values

Let's say you have a form and you have this arraylist in your form

You Action form:

public class MyForm extends ActionForm{
    public List<FieldTo> fieldsList;
    //getters setters

}

You jsp page:

<logic:iterate name="nameOfMyForm" property=""fieldsList" id="field" type="com.package.FieldTo">
    <td><bean:write name="field" property="fieldId"></td>
    <td><bean:write name="field" property="category"></td>
    <td><bean:write name="field" property="organization.name"></td>
</logic:iterate>

Organization.java

public Class Organization{
    private String name; 
    //getters and settersa
}

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