package com.yourcompany.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class CheckboxForm extends ActionForm {
/*
* Generated fields
*/
/** one property */
private String[] ch=new String[0];
/*
* Generated Methods
*/
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}
/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
public String[] getCh() {
return ch;
}
public void setCh(String[] ch) {
this.ch = ch;
}
}
.......
.....
<logic:present name="adminqueslist">
<logic:iterate id="adminqueslist" name="adminqueslist" >
<tr>
<td width="50" align="center" bgcolor="#FFFFFF">
<html:multibox name="checkboxForm" property="ch"/>
</td>
<td style="font-family: 宋体; font-size: 12px; padding-left:4px" width="76" bgcolor="#FFFFFF" height="25">
<bean:write name="adminqueslist" property="plateName" />
</td>
<td style="font-family: 宋体; font-size: 12px; padding-left:4px" bgcolor="#FFFFFF" height="25">
<bean:write name="adminqueslist" property="plateInstr" />
</td>
</tr>
</logic:iterate>
</logic:present>
</table>
</td>
</tr>
<tr>
<td style="font-family: 宋体; font-size: 12px" height="30">
<html:submit value="删除选定类别"/>
</td>
</tr>
</html:form>
package com.yourcompany.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.ks.hulu.disdaoimpl.DisDaoImpl;
import com.yourcompany.struts.form.CheckboxForm;
public class DeletePlateAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
CheckboxForm checkboxForm=new CheckboxForm();
String plateId = request.getParameter("plateId");
String[] selectedItems = new String[0];
selectedItems = checkboxForm.getCh();
for ( int i = 0 ; i < selectedItems.length ; ++i ){
System.out.println( "selected " + i + ": " + selectedItems[i]);
}
return mapping.getInputForward();
}
}
异常:
org.apache.jasper.JasperException: You must specify the value attribute or nested tag content
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
----------------解决方案--------------------------------------------------------