我正在尝试制作一个登录屏幕,所以我得到了 ıbanNumber 并从用户那里传递并在数据库上检查它。这是可行的,但是当我尝试在另一个页面上使用 `doldur() 来获取具有相同 ıbanNumber 的数据库上的一些信息时,它返回 null。
我该如何解决这种情况,为什么 ibanNumber 返回 null ?
不:当我点击“Kullanici İslem Menusu.xhtml”页面上的“hesap işlemleri”按钮然后打开“hesap işlemleri.xhtml”并填写数据表时添加jsf页面
@ManagedBean(name = "login")
public class LoginBean {
public LoginBean() {
}
private String ıban_number;
private String sifre;
private String paraCek;
private String paraYatir;
public String getParaCek() {
return paraCek;
}
public void setParaCek(String paraCek) {
this.paraCek = paraCek;
}
public String getParaYatir() {
return paraYatir;
}
public void setParaYatir(String paraYatir) {
this.paraYatir = paraYatir;
}
public String getIban_number() {
return ıban_number;
}
public void setIban_number(String ıban_number) {
this.ıban_number = ıban_number;
}
public String getSifre() {
return sifre;
}
public void setSifre(String sifre) {
this.sifre = sifre;
}
db_connection dbLogin = new db_connection();
private PreparedStatement psLogin;
private ResultSet rsLogin;
public String getLogin() {
try {
System.out.println(getIban_number() + " " + getSifre());
psLogin = dbLogin.getCon().prepareStatement("select * from kullanici_giris where ibanNumber=? and sifre=?");
psLogin.setString(1, getIban_number());
psLogin.setString(2, getSifre());
System.out.println("Veri tabanına ulaşıldı");
rsLogin = psLogin.executeQuery();
while (rsLogin.next()) {
return "true";
}
} catch (SQLException ex) {
Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex);
}
return "false";
}
public List<getAccountInfo> doldur() {
System.out.println(getIban_number());
List<getAccountInfo> liste = new ArrayList<getAccountInfo>();
try {
psLogin = dbLogin.getCon().prepareStatement("SELECT * FROM hesap_bilgi where ibanNumber = ? ");
psLogin.setString(1, getIban_number());
rsLogin = psLogin.executeQuery();
while (rsLogin.next()) {
getAccountInfo obj = new getAccountInfo();
obj.setIbanNumber(rsLogin.getString(1));
obj.setToplamButce(rsLogin.getString(2));
obj.setHarcananButce(rsLogin.getString(3));
obj.setKalanButce(rsLogin.getString(4));
liste.add(obj);
}
} catch (SQLException ex) {
}
return liste;
}
}
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html">
<h:head>
<title>Kullanici İslem Menusu</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="1">
<h:commandButton value="Hesap İşlemleri" action="hesap_islemleri"/>
<h:commandButton value="Kişisel İşlemleri" action="kisisel_islemler"/>
<h:commandButton value="Şubelerimiz" action="subelerimiz"/>
</h:panelGrid>
</h:form>
</h:body>
</html>
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<h:dataTable value="#{login.doldur()}" var="c">
<h:column>
<f:facet name="header">
<h:outputLabel value="ıbanNumber"/>
</f:facet>
<h:outputLabel value="#{c.ibanNumber}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel value="ToplamButce"/>
</f:facet>
<h:outputLabel value="#{c.toplamButce}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel value="HarcananButce"/>
</f:facet>
<h:outputLabel value="#{c.harcananButce}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel value="KalanButce"/>
</f:facet>
<h:outputLabel value="#{c.kalanButce}"/>
</h:column>
</h:dataTable>
</h:form>
</h:body>
</html>