如果成功,谁能帮我读取数据库值并将其传递到 jsf 中的下一页。
这是我的代码。
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/templates/template.xhtml"
xmlns:rich="http://richfaces.org/rich">
<ui:define name="body">
<h:form>
<rich:panel header="Employee Log In Page" style="width: 315px">
<h:panelGrid columns="2">
<h:outputText value="EmployeeId: " />
<h:inputText id="employeeId" value="">
<f:validateLength minimum="30" maximum="30" />
</h:inputText>
<h:outputText id= "password" value="PassWord: " />
<h:inputText value="">
<f:validateLength minimum="15" maximum="15" />
</h:inputText>
<h:commandButton action="#{ }" value="Log In" />
</h:panelGrid>
</rich:panel>
</h:form>
</ui:define>
</ui:composition>
连接性.java
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.ArrayList;
import antlr.collections.List;
import com.model.UserDetails;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
public class Connectivity {
public static void main(String[] argv) {
System.out.println("-------- MySQL JDBC Connection Testing ------------");
int i=0;
Connection con ;
Statement ps;
ResultSet rs;
try
{
Class.forName("com.mysql.jdbc.Driver");
con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/LeaveApp",
"root","root");
ps = (Statement) con.createStatement();
rs = ps.executeQuery("select * from Login");
while(rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getString(3));
i++;
}
}
catch (Exception e)
{
System.out.println("Error Data : " + e.getMessage());
}
}
}
用户详细信息.java
package com.model;
public class UserDetails {
public int login_id;
public String user_name;
public String user_password;
public int getLogin_id() {
return login_id;
}
public void setLogin_id(int login_id) {
this.login_id = login_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_password() {
return user_password;
}
public void setUser_password(String user_password) {
this.user_password = user_password;
}
}
我需要验证登录页面。怎么做。