使用 JPA 和 Eclipselink 在 JSP 文件中显示来自现有数据库 table 的数据
Using JPA and Eclipselink to display data from existing database table in a JSP file
不确定我是否遗漏了这个过程中的某个步骤,或者它是否只是语法,因为我是这个结构的新手。我现在只打算回到我的 bean,但如果需要,我可以提出我的逻辑 class、模型 class 和其他任何东西。
这就是我的 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>
这是 Bean:
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 数据 table.
中值参数中调用的内容得到解决
Bean -> getExampleList()
jsp -> 值="#{bean.ExampleList}"
只有当我想将 ArrayList 保持为私有时才会这样做,因为我收到的错误是因为变量是私有的并且 gettter 与我调用的不匹配。
不确定我是否遗漏了这个过程中的某个步骤,或者它是否只是语法,因为我是这个结构的新手。我现在只打算回到我的 bean,但如果需要,我可以提出我的逻辑 class、模型 class 和其他任何东西。 这就是我的 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>
这是 Bean:
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 数据 table.
中值参数中调用的内容得到解决Bean -> getExampleList() jsp -> 值="#{bean.ExampleList}"
只有当我想将 ArrayList 保持为私有时才会这样做,因为我收到的错误是因为变量是私有的并且 gettter 与我调用的不匹配。