HTML: Select supports multiple choices. It is very easy to select multiple choices. The background accepts a string. What should I do when multiple choices are made?
1. To create a multi-choice select control, you need to add Code such as multiple = "true" to the attribute list, as shown below:
-
Code: select all
-
<%
for (i=0; i<userlist.size(); i++) {
tmpstring = (String)userlist.get(i);
%>
<%
}
%>
2. After being defined as multiple, the field in the corresponding actionformbean should be defined as a string array. Note that arraylist or other things cannot be used, but only a string array can be used, as shown below:
-
Code: select all
-
<!-- Create UG Queue Limit Action -->
<action path="/CreateUGQueueLimit"
type="com.jointforce.action.CreateUGQueueLimitAction"
name="CreateUGQueueLimitForm"
scope="request"
input="createugqueuelimit">
<forward name="moduleunavailable" path="/jsp/joblimitunavailable.jsp"/>
<forward name="createugqueuelimit" path="/jsp/createugqueuelimit.jsp"/>
<forward name="success" path="/jsp/createugqueuelimitresult.jsp"/>
</action>
<!-- Create UG Queue Limit -->
<form-bean name="CreateUGQueueLimitForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userlist" type="java.lang.String[]"/>
<form-property name="grouplist" type="java.lang.String[]"/>
<form-property name="hostlist" type="java.lang.String[]"/>
</form-bean>
Validation. XML is still in use:
-
Code: select all
-
<form name="CreateUGQueueLimitForm">
<field property="userlist"></field>
<field property="hostlist"></field>
<field property="grouplist"></field>
</form>
Finally, in the action class, we can get the following:
String [] userlist = (string []) propertyutils. getproperty (form, "userlist ");
You can use a for loop to retrieve the stuff:
For (INT I = 0; I <userlist. length; I ++ ){
System. Out. println (userlist [I]);
}