gpt4 book ai didi

jsf-2 - 数据表中输入字符串的 NumberFormatException

转载 作者:行者123 更新时间:2023-12-02 02:01:33 26 4
gpt4 key购买 nike

我在我的 DAO 中使用以下方法检索人员列表:

public List<Personne> getAllUsers() {

Query query = em.createQuery("SELECT p FROM Personne p where TYPE(p) =Utilisateur");
@SuppressWarnings("unchecked")
List <Personne> personnes = query.getResultList();
return personnes;
}

我想在数据表中显示人员列表:

  <p:dataTable value="#{desacBean.users}" var="us" paginator="true" selection="#  {desacBean.selectedUser}" selectionMode="single" rowKey="#{desacBean.getId(us)}}"   first="1">           

<p:ajax event="rowSelect" listener="#{desacBean.onUserSelect}"/>

<p:column>
<f:facet name="n">
<h:outputText value="nom" />
</f:facet>
<h:outputText value="#{us.nom}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="prenom" />
</f:facet>
<h:outputText value="#{us.prenom}"/>
</p:column>
</p:dataTable>

我的 bean :

@ManagedBean(name="desacBean")
@SessionScoped
public class DesactiveBean implements Serializable{


private static final long serialVersionUID = 1L;
private List<Personne> users = new ArrayList<Personne>();
private Personne selectedUser;
private boolean panelRendered;
UserDAO daoUser = new UserDaoImpl();

public void rowSelect(SelectEvent event){
selectedUser = (Personne)event.getObject();
System.out.println("selectedUser = "+selectedUser.getNom_ut());
this.panelRendered = true;
}
public int getId(Personne car)
{
return System.identityHashCode(car);
}

public void onUserSelect(SelectEvent event){
this.selectedUser = (Personne)event.getObject();
System.out.println("selectedUser = "+selectedUser.getNom_ut());

}

尝试显示此数据表时出现以下错误:

java.lang.NumberFormatException: For input string: "prenom"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
For input string: "prenom"

我该如何解决?

最佳答案

您可能会遇到与此处回答的问题相同的问题:NumberFormatException for input String

关于jsf-2 - 数据表中输入字符串的 NumberFormatException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17010406/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com