我有一个名为 Experiment 的 bean,它的属性是一个名为 Assay 的 bean 的数组列表。
在 jsp 中,我想遍历存储在 Experiment bean 中的化验列表,我尝试这样做:
<c:forEach items="${exp.assays}" var="ay">
<tr><td>${ay.decision}</td><td>${ay.comment}</td></tr>
</c:forEach>
'decision' 和 'comment' 是 Assay bean 的属性。
但这不起作用。我得到错误:
SEVERE: javax.el.PropertyNotFoundException: The class 'beans.Experiment' does not have the property 'decision'.
好像“exp.assays”列表中的项目是豆类实验而不是我所期望的化验。
所以我尝试在 forEach 循环中访问 Experiment 属性(eid,我知道我可以通过直接编写 ${exp.eid} 来访问它),如下所示:
<c:forEach items="${exp.assays}" var="ay">
<tr><td>${ay.eid}</td></tr>
</c:forEach>
但后来我收到错误消息:
SEVERE: javax.el.PropertyNotFoundException: The class 'beans.Assay' does not have the property 'eid'.
任何知道发生了什么或我该如何解决的人?
完整的 bean 代码很长,但这里是我认为相关的部分
实验:
public class Experiment extends dataItem implements Serializable {
private String eid;
private List<Assay> assays = new ArrayList();
public String getEid() {
return eid;
}
public void setEid(String id) {
eid = id;
}
public List<Assay> getAssays() {
return assays;
}
public void setAssays(List<Assay> assays) {
this.assays = assays;
}
}
和化验:
public class Assay extends dataItem implements Serializable {
private Integer id;
private stock antigen;
private String decision;
private String comment;
private String freeAb;
private List<AssayData> data;
private List<conjugate> conjugates = new ArrayList();
public List<conjugate> getConjugates() {
return conjugates;
}
public void setConjugates(List<conjugate> conjugates) {
this.conjugates = conjugates;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public stock getAntigen() {
return antigen;
}
public void setAntigen(String id) {
stock s = new stock();
s.setSID(id);
this.antigen = s;
}
public String getDecision() {
return decision;
}
public void setDecision(String decision) {
this.decision = decision;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getFreeAb() {
return freeAb;
}
public void setFreeAb(String freeAb) {
this.freeAb = freeAb;
}
public List<AssayData> getData() {
return data;
}
public void setData(List<AssayData> data) {
this.data = data;
}
}