1

我正在使用 struts 1.3 开发一些员工注册应用程序。在一个 jsp 页面上,一个表格显示了所有注册请求,包括该特定员工的所有详细信息(每个员工注册请求一行)。每行包含两个已批准和拒绝的单选按钮。管理员必须选择他可以跳过几行的任何一个(使其挂起)。按下提交按钮后,如何根据管理员的选择一一读取所有单选按钮值以更新数据库。

我尝试了什么:

  1. DataAccess.java 类(处理集合的 Bean)

    public class DataAccess {
    
        private String regid,fname,lname,email,eid,contact,address,jdate,qualification,designation,adminchoice,imagepath;
        private String reqdate,approvedate,rejectdate,ipaddress;
    
        ArrayList<DataAccess> userList;
    
        //write the public constructors....        
        public DataAccess(){ }
    
        public DataAccess(String regid,String fname, String lname,String email,String eid,String contact,String address,String jdate,String qualification,String designation,String adminchoice,String imagepath,String reqdate,String approvedate,String rejectdate,String ipaddress)
        {
            this.regid=regid;
            this.fname=fname;
            this.lname=lname;
            this.email=email;
            this.eid=eid;
            this.contact=contact;
            this.address=address;
            this.jdate=jdate;
            this.qualification=qualification;
            this.designation=designation;
            this.adminchoice=adminchoice;
            this.imagepath=imagepath;
            this.reqdate=reqdate;
            this.approvedate=approvedate;
            this.rejectdate=rejectdate;
            this.ipaddress=ipaddress;
        }
    
        //Setter and getter methods for all properties...
    
        //for registration id....
        public void setRegid(String regid) { this.regid=regid;}
        public String getRegid(){ return regid;}
    
        // for first name....   
        public void setFname(String fname) { this.fname=fname;}
        public String getFname() { return fname;}
    
        //for last name....
        public void setLname(String lname) { this.lname=lname;}
        public String getLname(){ return lname;}
    
        //for email....
        public void setEmail(String email) { this.email=email;}
        public String getEmail(){ return email;}
    
        //for eid....
        public void setEid(String eid) { this.eid=eid;}
        public String getEid(){ return eid;}
    
        //for contact no....
        public void setContact(String contact) { this.contact=contact;}
        public String getContact() { return contact; }
    
        //for address....
        public void setAddress(String address){ this.address=address;}
        public String getAddress(){ return address;}
    
        //for joining date....
        public void setJdate(String jdate){ this.jdate=jdate;}
        public String getJdate(){ return jdate;}
    
        //for qualification....
        public void setQualification(String qualification) { this.qualification=qualification;}
        public String getQualification(){ return qualification; }
    
        //for experience....
        public void setDesignation(String designation) { this.designation=designation;}
        public String getDesignation() { return designation;}
    
        //for admin choice....
        public void setAdminchoice(String adminchoice){ this.adminchoice=adminchoice;}
        public String getAdminchoice(){ return adminchoice; }
    
        //for image path....
        public void setImagepath(String imagepath){ this.imagepath=imagepath;}
        public String getImagepath(){ return imagepath; }
    
        //for registration request date....
        public void setReqdate(String reqdate) { this.reqdate=reqdate;}
        public String getReqdate(){ return reqdate;}
    
        //for registration approval date....
        public void setApprovedate(String approvedate) { this.approvedate=approvedate;}
        public String getApprovedate(){ return approvedate;}
    
        //for registration rejection date....
        public void setRejectdate(String rejectdate) { this.rejectdate=rejectdate;}
        public String getRejectdate(){ return rejectdate;}
    
        //for ip address....
        public void setIpaddress(String ipaddress) { this.ipaddress=ipaddress;}
        public String getIpaddress(){ return ipaddress;}
    
        public ArrayList<DataAccess> createList()
        {
            userList=new ArrayList<DataAccess>();
            return userList;
        }
    
        public void addData(DataAccess da)
        {
            userList.add(da);
        }
    }
    
  2. 在我的 ActionForm 课程中

    private ArrayList<DataAccess> dataList;
    public void setDataList(ArrayList<DataAccess> dataList) {this.dataList = dataList;}
    public ArrayList<DataAccess> getDataList() {return dataList;}
    
  3. 在我的 Action 类中执行方法():此方法将控件发送到一个 jsp 页面(Pending.jsp),我在其中显示所有待处理的请求。在此页面控件转到同一 DispatchAction 类的approveUsers(----) 方法以更新数据库之后。

    DataAccess dtacs=new DataAccess();
    ArrayList<DataAccess> userList=dtacs.createList();
    
    do{
        if(rs3.next())
        {
            System.out.println("BBB.");
            jdate_string=new SimpleDateFormat("dd/MMM/YYYY").format(rs2.getDate(7));
            reqdate_string=new SimpleDateFormat("hh:mm:ss a
            dd/MMM/YYYY").format(rs2.getTimestamp(14)); 
    
            userList.add(new DataAccess(rs2.getString(1),rs2.getString(3),rs2.getString(4),
            rs3.getString(1),  rs2.getString(13),rs2.getString(5),rs2.getString(6),jdate_string,
            rs2.getString(8),rs2.getString(9),"no",rs2.getString(12),reqdate_string,"Not Approved",
            "Not Rejected",rs3.getString(2)));
    
            System.out.println(userList.size());
        }//if closing..
    
    } while(rs1.next());
    
    req.setAttribute("data", userList);
    return map.findForward("gopending");
    
  4. 我的 Jsp 页面代码(Pending.jsp)

    <logic:iterate id="item" name="data" indexId="idx">
        <tr>
            <td><bean:write name="idx"/></td>
            <td><bean:write name="item" property="regid"/></td>
            <td><bean:write name="item" property="eid"/></td>
            <td><bean:write name="item" property="fname"/></td>
            <td><bean:write name="item" property="lname"/></td>
            <td><bean:write name="item" property="designation"/></td>
            <td><bean:write name="item" property="email"/></td>
            <td><bean:write name="item" property="contact"/></td>
            <td><bean:write name="item" property="address"/></td>
            <td><bean:write name="item" property="qualification"/></td>
            <td><bean:write name="item" property="jdate"/></td>
            <td><bean:write name="item" property="reqdate"/></td>
            <td><bean:write name="item" property="ipaddress"/></td>
            <td><html:radio name="item" property="dataList"  indexed="true" value="approved"/></td>
            <td><html:radio name="item" property="dataList"  indexed="true" value="rejected"/></td> 
        </tr>
    </logic:iterate>
    

问题是,如果我没有放置单选按钮,它会正确显示数据。当我尝试放置单选按钮(用于管理员选择批准或拒绝)时,我收到此错误:

javax.servlet.jsp.JspException: No getter method available for property dataList for bean under name item

我还尝试将这些 getter 和 setter 放在 DataAccess.java(用于收集的 Bean 类)和 AppForm 类(FormBean)中,但没有运气..

public void setItem(int index,DataAccess value){this.dataList.add(index,value);}
public DataAccess getItem(int index){return this.dataList.get(index);}

任何帮助,建议将不胜感激。

4

1 回答 1

0

最后我解决了这个问题。

以下是处理此问题的一些建议

1)Follow the above steps.
2)I did a silly mistake, while taking the radio buttons put property="adminchoice" (in my case).
3) Read the corresponding admin choice in the execute method of Action class where control goes after submitting form.
于 2013-03-07T10:07:09.143 回答