补充一下,bean里面都写了get方法,只是我没写出来

解决方案 »

  1.   

    ResultSet rs=DBOperate.dbQuery(sql);
        if (rs.next())
        {
          name=rs.getString("name");
        }
      

  2.   

    着块没问题,因为只有一条数据,而且我在main里面测试过了,都能读出来,就是用在jsp的bean中不行啊
      

  3.   

    这是member.jsp页面
    <%@page contentType="text/html; charset=gb2312" language="java"%>
    <html>
    <head>
    <title>溢洋论坛</title>
    </head>
    <body text="#0000ff" >
    <table cellspacing="0" cellpadding="0" border="0" width="99%" align="center">
    <tr>
        <p align="center">查看用户资料</p>
    </tr>
      <jsp:useBean id="memberClass" scope="page" class="entity.sys.Member"/>
      <%!String loginName;%>
      <%
         memberClass.fillByLoginName("dpli");
      %>
             <tr bgcolor="#F7FBFF"> 
               <td width="42%">名称</td> 
               <td bgcolor="#F7FBFF" width="58%"><%=memberClass.getLoginName()%>&nbsp;</td>
             </tr>
             <tr bgcolor="#F7FBFF"> 
               <td width="42%">用户昵称</td> 
               <td bgcolor="#F7FBFF" width="58%"><%=memberClass.getNikeName()%>&nbsp;</td>
             </tr>
             <tr bgcolor="#F7FBFF"> 
               <td width="42%">用户姓名</td> 
               <td bgcolor="#F7FBFF" width="58%"><%=memberClass.getRealName()%>&nbsp;</td>
             </tr>
            <tr bgcolor="#F7FBFF"> 
              <td width="42%">姓别</td>
              <td width="58%"><%=memberClass.getSex()%>  </td>
            </tr>
            <tr bgcolor="#F7FBFF"> 
              <td width="42%">居住地址</td>
              <td width="58%"><%=memberClass.getAddress()%>  </td>
    </tr>
    </table>
    </body>
    </html>
      

  4.   

    这是Member.java
    //网站会员
    public class Member extends Person
    {
        //积分
        private int integral;
        //用户级别
        private int level;
        //购物次数
        private int consumeTimes;
        //账户余额
        private double balance;
        //消费总金额
        private double ConsumeAmount;    public Member()
        {
            init();
        }
        public boolean fillByLoginName(String loginName)
        {
            if (loginName == null || loginName.equals(""))
            {
                return false;
            }
            boolean rlt = false;
            String sql = "select loginName,loginPass,userType,nickName," 
                        + "realName,Sex,Age,Phone,Mobile,Email,Address,JoinDate," 
                        + "integral,level,consumeTimes,balance,consumeAmount "
                        + "from e_sys_member where loginName='" 
                        + loginName + "'";
            ResultSet rs = DatabaseOperate.dbExecuteQuery(sql);
            this.loginName = loginName;
            try
            {
                if (rs != null && rs.next())
                {
                    this.loginPass = rs.getString("loginPass");
                    this.nikeName = rs.getString("nickName");
                    this.realName = rs.getString("realName");
                    this.sex = rs.getString("sex");
                    this.age = rs.getInt("age");
                    this.phone = rs.getString("phone");
                    this.mobile = rs.getString("mobile");
                    this.email = rs.getString("email");
                    this.address = rs.getString("address");
                    this.joinDate = rs.getDate("joinDate");
                    this.integral = rs.getInt("integral");
                    this.level = rs.getInt("level");
                    this.consumeTimes = rs.getInt("consumeTimes");
                    this.balance = rs.getDouble("balance");
                    this.ConsumeAmount = rs.getInt("consumeAmount");
                    rlt = true;
                }
            }
            catch (SQLException e)
            {
                e.printStackTrace();
                rlt = false;
            }
            return rlt;
        }
        public void init()
        {
            super.init();
            integral = 0;
            level = GlobalData.Member.Level.LEVEL_0;
            consumeTimes = 0;
            balance = 0;
            ConsumeAmount = 0;
        }
        public double getBalance()
        {
            return balance;
        }    public double getConsumeAmount()
        {
            return ConsumeAmount;
        }    public int getConsumeTimes()
        {
            return consumeTimes;
        }    public int getIntegral()
        {
            return integral;
        }
        public int getLevel()
        {
            return level;
        }}
      

  5.   

    这是Person.java
    package entity;import java.util.Date;import util.GlobalData;
    //joinDate字段可能为空
    public class Person extends Entity
    {
        //用户名为索引
        protected String loginName;
        protected String loginPass;
        protected String nikeName;
        protected String realName;
        protected String sex;
        protected int age;
        protected String phone;
        protected String mobile;
        protected String email;
        protected String address;
        protected Date joinDate; // new Date(GlobalData.Global.INIT_DATA_STR);
       
        public Person()
        {
            init();
        }
        
        protected void init()
        {
            loginName = "";
            loginPass = "";
            nikeName = "";
            realName = "";
            sex = "";
            age = GlobalData.Global.INIT_AGE;
            phone = "";
            mobile = "";
            email = "";
            address = "";
            joinDate = null; // new Date(GlobalData.Global.INIT_DATA_STR);    }
        public static void main(String[] args)
        {
        }
        public String getAddress()
        {
            return address;
        }    public int getAge()
        {
            return age;
        }
        public String getEmail()
        {
            return email;
        }
        public Date getJoinDate()
        {
            return joinDate;
        }
        public String getLoginName()
        {
            return loginName;
        }
        public String getLoginPass()
        {
            return loginPass;
        }
        public String getMobile()
        {
            return mobile;
        }
        public String getNikeName()
        {
            return nikeName;
        }
        public String getPhone()
        {
            return phone;
        }
        public String getRealName()
        {
            return realName;
        }
        public String getSex()
        {
            return sex;
        }}
      

  6.   

    memberClass.fillByLoginName("dpli");是否返回true
      

  7.   

    我测过了返回false,原因是ResultSet=null,但是如果在main里面测试则不会为null
      

  8.   

    请问大虾为什么,在main里面ResultSet不为空,在jsp中却为空,为什么呢