【发布时间】:2014-07-18 10:06:59
【问题描述】:
我不明白为什么会出现此错误!我似乎已经为被调用的对象属性建立了正确的命名约定。
我正在将对象列表返回到 .jsp 页面,并尝试遍历列表并使用 JSTL 访问每个属性属性,如下所示:
<h2>Latest Testimonials</h2>
<c:forEach items="${testimonialList}" var="testimonial">
<p><span class="quote">"${testimonial.getTestimonial}"</span> by ${testimonial.getAuthor</p>
</c:forEach>
这是见证对象:
public class Testimonial {
private String testimonial, author, date;
// message get/set
public String getTestimonial(){
return testimonial;
}
public void setTestimonial(String testimonial){
this.testimonial = testimonial;
}
// name get/set
public String getAuthor(){
return author;
}
public void setAuthor(String author){
this.author = author;
}
// date get/set
public String getDate(){
return date;
}
public void setDate(String date){
this.date = date;
}
}
完整的错误:
javax.el.PropertyNotFoundException: 属性 'getTestimonial' 不是 在 uk.co.morleys.Testimonial 类型上找到
为什么找不到属性?
【问题讨论】:
标签: java jsp properties jstl el