【发布时间】:2012-10-23 08:39:18
【问题描述】:
如何在 jsf 2.0 中显示来自两个连接表的数据?
我已经管理了 bean 目录(代表我数据库中的表):
public class Catalog implements Serializable{
//gettters and setters and atrributes }
我还有另一个托管 bean(代表我数据库中的另一个表):
public class Profit implements Serializable{
//gettters and setters and attributes}
我有一个返回查询的方法,该方法将这两列(来自数据库)与 Catalog id 属性连接起来。
我不知道该方法的返回值是什么,以及如何在 jsf xhtml 页面中显示连接数据...
这是我的方法:
public <what return value to put> method throws Exception {
connect(); //to databse
String query="SELECT....";
//this query is prefectly good, i tested it in sql server, it does the job
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery(upit);
while(rs.next()) {
//setting the values from my databse
}
return <what to return here> //this is the trick part
}
要设置什么返回值以及如何在xhtml页面上显示
【问题讨论】: