I want to get value from arraylist in java.
I can show traininglist in HTML by using
model.addAttribute("traininglist",traininglist);
and get the each value by using :
tr : ${traininglist}
then
tr.trainingduration
but I now I want to get traininglist value in java, please help me here's my code
List<TrainingModel> traininglist = viewTraining(biodataId);
and there's my trainingmodel class
public class TrainingModel {
@Id
@Column(name="id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name="is_delete")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private boolean isDelete;
@Column(name="biodata_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long biodataId;
@Column(name="training_name")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String trainingName;
@Column(name="organizer")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String organizer;
@Column(name="training_year")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String trainingYear;
@Column(name="training_month")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private String trainingMonth;
@Column(name="training_duration")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int trainingDuration;
//getter setter
}
To see all the objects in the arrayList, you can use: System.out.println(traininglist);
or you can loop through the training list like this:
for(TrainingModel listElement : traininglist){
listElement.(use the getter of any of the fields to get the Object property)
}
Hope this helps.
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.