的index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:form>
<p:outputLabel value="Primefaces Tutorial"></p:outputLabel>
<p:dataTable value="#{Liste.dizgi}" var="liste">
<p:column>
<f:facet name="header">
<h:outputText value="Agent_code"></h:outputText>
</f:facet>
<h:outputText value="#{liste.Agent_code}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Date"></h:outputText>
</f:facet>
<h:outputText value="#{liste.date}"></h:outputText>
</p:column>
</p:dataTable>
</h:form>
</html>
Liste.java
package pro;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.ManagedBean;
import javax.annotation.PostConstruct;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class Liste {
private List<Veri> dizgi=new ArrayList<Veri>();
public List<Veri> getDizgi() {
return dizgi;
}
public void setDizgi(List<Veri> d) {
this.dizgi = d;
}
public Liste(){};
@PostConstruct
void Listele(){
dizgi.add(new Veri("B-8821083","20150513",-1,-29));
dizgi.add(new Veri("B-8821083","20150521",46,4.718));
dizgi.add(new Veri("B-8821083","20150602",-5,-455));
dizgi.add(new Veri("B-8821083","20150623",-4,-305));
dizgi.add(new Veri("B-8821083","20150506",7,0));
dizgi.add(new Veri("B-8821083","20150612",1,0));
dizgi.add(new Veri("B-8821083","20150615",50,4.602));
}
}
这是代码,当我运行此代码时。它说
未找到任何记录。
任何想法,这里有什么问题? 我试图将List两个属性打印为列。它没有给出错误。只显示没有找到记录。但实际上存在很多元素。 有一个veri类。它提供了诸如Agent_Code和date以及getter和setter方法等属性。