日期:2014-05-18  浏览次数:20849 次

定义了bean,为什么还是出现No getter method for property name of bean 错误
1调用Action的页面


<input   type= "button "   value= "联系人 "   name= "contact "   onClick= "window.open( 'showContact.do ', '_blank ', 'scrollbars=no,status=no,width=300,height=300 ') "> <br/>  
信息内容(70字内) <br> &nbsp; <html:textarea   property= "message "     cols= "40 "   rows= "5 "/> <html:errors   property= "message "/> <br/>

2   action

public   ActionForward   execute(ActionMapping   mapping,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse   response)   {
//   TODO   Auto-generated   method   stub
String   prompt;
 
getContactDAO   gcDAO=new   getContactDAO();
boolean   mark=gcDAO.getData();
if(mark)   {
prompt= "success ";
request.setAttribute( "contacts ",   gcDAO.commonContactList);
}


else   prompt= "fail ";
return   mapping.findForward(prompt);
}
}

3   DAO

public   class   getContactDAO   {
public   getContactDAO(){

}
  public
List   commonContactList=new   ArrayList();


  public   boolean   getData   ()
    {
    boolean   GetRs=false;
   
    Connection   conn;    
    ResultSet   rs;    
    conn=dbPool.getConnection();
   
   
        try{
            Statement   stmt=conn.createStatement();
    String   sql= "select   *   from   CommonContactList ";    
    rs=stmt.executeQuery(sql);
    while(rs.next()){
    CommonContact   CContact=new   CommonContact();
    CContact.setName(rs.getString( "cname "));
    CContact.setMobile(rs.getString( "cmobile "));
    commonContactList.add(CContact);
   
    }

    GetRs=true;
          }catch   (SQLException   e){GetRs=false;}

     
         
    return   GetRs;

    }
   
}


4   bean


      class   CommonContact{
      public   String   name;
      public   String   mobile;
   
    public   CommonContact(){
   
    }
   
    public   String   getName(){
    return   name;
    }
    public   void   setName(String   name){
  this.name=name;
   
    }
    public   Stri