If you want to assign multiple operations to a form. For example:
In this form, you want to have two actions: "Delete" and "move. However, a form only processes one action.
How can we use one action to deal with two different operations?
In the servlet parameter httpservletrequest req, there is a function named getparameternames ().
This parameter indicates:
-
Returns
EnumerationOf
StringObjects ining the names of the parameters contained in this request. If the request has no parameters, the method returns an empty
Enumeration.
-
-
Returns:
-
An
EnumerationOf
StringObjects, each
StringContaining the name of a request parameter; or an empty
EnumerationIf the request has no parameters
In other words, it can return the names of all parameters in the request object.
In this way, we can assign different buttons with different names to distinguish which operation we click.
For example:
Print the array returned by the getparameternames () function in the servlet and you can see:
When we click"Delete", The output content is:
When we click"Mobile", The output content is:
That is to say, each operation only has one operation. Therefore, you only need to make logical judgments to know what operations the selected checkbox is intended.