我编写了这个函数来从 MySQL 数据库中获取项目列表到 JSP 中:
public List getBookList() throws SQLException
{
List BookList = new ArrayList();
ResultSet results = statement.executeQuery("SELECT * FROM book" );
while ( results.next() ) {
BookBean view = new BookBean();
view.setID(results.getString( 1 ));
view.setName(results.getString( 2 ));
view.setDescription(results.getString( 3));
view.setCatID(results.getString( 4));
view.setUID(results.getString(5 ));
view.setDateAdded(results.getString( 6 ));
view.setPicThumb(results.getString( 7 ));
view.setPicLarge(results.getString( 8 ));
BookList.add(view);
}
return BookList;
}
如何调用此方法在 .jsp 页面上呈现我的结果集,是否有更好的方法来重写此方法?