sql语句是select * from 表名,把所有的数据显示到jsp中,先不用分页,中间一要用到servlet(本人是不是专业学java的,所以不要用struts这样高级的东西,用setAttribute和getAttribute就好了

解决方案 »

  1.   

    public List selectArticleByType() throws SQLException{
    List theList=new ArrayList();
    String sql="select top  * from ARTICLE ";
    try {
    conn=dbconn.getConnection();
    pstmt=conn.prepareStatement(sql);
    rs=pstmt.executeQuery();
    while(rs.next()){
    Aritcle aritcle=new Aritcle();
    aritcle.setArticleId(rs.getInt("articleId"));
    aritcle.setTitle(rs.getString("title"));
    aritcle.setContent(rs.getString("content"));
    aritcle.setType(rs.getInt("type"));
    aritcle.setWriter(rs.getString("writer"));
    aritcle.setWriteDate(rs.getString("writeDate"));

    theList.add(aritcle);
    }
    } catch (RuntimeException e) {
    e.printStackTrace();
    }finally{
    dbconn.closeAll(conn, pstmt, rs);
    }

    return theList;
    }
    Servlet调用这个方法,接收List 把List对象保存到session中。转向页面就可以。在页面中遍历List