使用JPA和Eclipselink在JSP文件中显示现有数据库表中的数据



不确定我在这个过程中是否遗漏了某个步骤,或者这只是语法,因为我是这个结构的新手。我现在只想回到我的bean,但如果需要的话,我可以建立我的逻辑类、模型类和其他任何东西。这就是我的JSP的样子:

<h:dataTable 
id="viewExampleTable" 
value="#{ExampleBean.exampleList}"
binding="#{ExampleBean.exampleTable}"
var="example"
styleClass="dataTable" border="1"
style="width: 500px; word-wrap: break-word;"
columnClasses="colWidth80,colWidth80,colWidth80,colWidth80">
<h:column>
<h:outputText value="example.Id"></h:outputText>
</h:column>
<h:column>
<h:outputText value="example.importDate"></h:outputText>
</h:column>
<h:column>
<h:outputText value="example.serviceId"></h:outputText>
</h:column>
<h:column>
<h:outputText value="example.rowTimestamp"></h:outputText>
</h:column>
</h:dataTable>

这就是憨豆:

private HtmlDataTable exampleTable;
private ArrayList exampleList = new ArrayList();
public HtmlDataTable getExampleTable(){
return this.exampleTable;
}
public void setExampleTable(HtmlDataTable dataTable){
this.exampleTable = dataTable;
}
public ArrayList<Example> getExample(){
ArrayList<Example> list = ExampleLogic.getExampleRecords();
this.exampleList = list;
return this.exampleList
}
public void setExample(ArrayList<Example> list){
this.exampleList = list;
}

我遇到的这个问题是,无论何时将其部署到服务器,我都会收到以下错误:

javax.faces.el.PropertyNotFoundException:从examplePath.view.ExampleBean 类型的bean获取属性"exampleList"时出错

只是一个空白屏幕。感谢任何帮助,因为我已经尽了最大的努力,不知道如何继续。

通过将Bean中的getter重命名为jsp数据表中value参数中调用的getter,解决了此问题。

Bean->getExampleList((jsp->value="#{bean.ExampleList}">

这只是在我想保持ArrayList私有的情况下,因为我收到的错误是因为变量是私有的,getter与我调用的不匹配。

最新更新