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

小透明求助,actionform取不到值
admin.jsp:


   <html:form action="/adminShow.do?flag=update" method="post">
    <table border="1" class="info_table">
<logic:notEmpty name="adminForm" property="adminList">
     <tr>
<th>用户名</th>
                        <th class="permission">性别</th>
     </tr>
     <logic:iterate id="admin" name="adminForm" property="adminList" indexId="indexid">
     <tr>
        <td><bean:write name="admin" property="adminName"/></td>
<td class="permission"><bean:write name='admin' property='permission'/>
      <html:select name="admin" property="permission" indexed="true">
           <html:option value="0">管理员</html:option>
           <html:option value="1">游客</html:option>
      </html:select>
                        </td>
     </tr>
</logic:iterate>
</logic:notEmpty>
</table>
<div class="btn_algin_center"><html:submit value="提交"/></div>
</html:form>
 
AdminShowAction.java:

public class AdminShowAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
String flag = request.getParameter("flag");
AdminForm af = (AdminForm) form;
if(flag.equals("showAll"))
{
af.setAdminList(NewList.makeList());

}
if(flag.equals("update")){
System.out.println(request.getAttribute("dlt"));
System.out.println(request.getAttribute("adminList"));
}
return mapping.findForward("success");
}
}


AdminForm.java:

public class AdminForm extends ActionForm {

private List<Admin> adminList = new AutoArrayList<Admin>(Admin.class);
public List<Admin> getAdminList() {
System.out.println("adminlist get "+adminList.get(0).getAdminName());
return adminList;
}
public void setAdminList(List<Admin> adminList) {
this.adminList = adminList;
System.out.println("adminlist set "+adminList.get(0).getAdminName());
}
}

Admin.java

public class Admin {
private String adminName;
private String adminPwd;
private String permission;
        //get set 略
}