当前位置: 代码迷 >> Java Web开发 >> checkbox Action传值有关问题
  详细解决方案

checkbox Action传值有关问题

热度:10071   发布时间:2013-02-25 21:12:24.0
checkbox Action传值问题
Action里写了getter、setter、并且字段名字也跟checkbox name的一样、但是就是取不到fieldValue的值

Jsp代码
  <s:iterator value="#request.list" id="us" status="sts">
  <tr>
  <td><s:checkbox name="checklist" value="false" fieldValue="#us.id"></s:checkbox>
  </td>
 
  <td><s:property value="#sts.index+1"/>
  </td>
 
  <td><s:property value="#us.firstname"/>
  </td> 
 
  <td><s:property value="#us.lastname"/>
  </td>
  <td><s:property value="#us.age"/>
  </td>
 
  <td><s:a href="DeleteUser.action?user.id=%{#us.id}">删除</s:a>
  </td>
 
  <td><s:a href="updateP.action?user.id=%{#us.id}">更新</s:a>
  </td>
  </tr>
  </s:iterator>
 
  <tr>
  <s:a href="DeleteAll.action">删除</s:a>
  </tr>

Action代码
public class DeleteAllUserAction extends ActionSupport {

private Userservice userservice;

ArrayList checklist=new ArrayList();


public Userservice getUserservice() {
return userservice;
}

public void setUserservice(Userservice userservice) {
this.userservice = userservice;
}

@SuppressWarnings("unchecked")
public ArrayList getchecklist() {
return checklist;
}

@SuppressWarnings("unchecked")
public void setchecklist(ArrayList checklist) {
this.checklist = checklist;
}

@Override
public String execute() throws Exception {
for (int j = 0; j <checklist.size(); j++) {
this.userservice.removeUser(userservice.findUserById(Integer.getInteger(checklist.get(j).toString())));
}

return SUCCESS;
}
}

------解决方案--------------------------------------------------------
public ArrayList getchecklist() {

方法名改成getChecklist
------解决方案--------------------------------------------------------
最好用<input type="checkbox"/>的方法
  相关解决方案