struts 的查询数据库显示问题和删除问题 在jsp页面显示 求大神指导思想 

解决方案 »

  1.   

    随便找本struts的书都会讲。。
      

  2.   

    public ArrayList<User> query() throws Exception{
    {
    ArrayList<User> list=new ArrayList<User>();
    String sql="select * from users where name like ?";
    Connection conn=null;
    PreparedStatement pstm=null;
    ResultSet rs=null;
    try{
    conn=DB.getConn();

    pstm=(PreparedStatement) conn.prepareStatement(sql);
    while(rs.next()){
    User user = new User();
    user.setUsername(rs.getString("1"));
    user.setPassword(rs.getString("password"));
    pstm.executeUpdate();
    }

    }catch (SQLException e) {
    e.printStackTrace();
    }
    return list;
    }

    }
    这是我的代码
      

  3.   

    public ArrayList<User> query() throws Exception{
    {
    ArrayList<User> list=new ArrayList<User>();
    String sql="select * from users where name like ?";
    Connection conn=null;
    PreparedStatement pstm=null;
    ResultSet rs=null;
    try{
    conn=DB.getConn();

    pstm=(PreparedStatement) conn.prepareStatement(sql);
    while(rs.next()){
    User user = new User();
    user.setUsername(rs.getString("1"));
    user.setPassword(rs.getString("password"));
    pstm.executeUpdate();
    }

    }catch (SQLException e) {
    e.printStackTrace();
    }
    return list;
    }

    }
    这是我的代码
      

  4.   

    把这个list放到一个action类中,在jsp页面配置到这个action上,用struts标签显示数据
      

  5.   

    能不能详细点啊 我不会啊 另外我有dao层 只是在execute()方法中不知道怎么写 查询数据库的方法写了 是List型 不会用啊
      

  6.   

    struts2权威指南 李刚找个pdf看看吧,查询代码有点问题……