Detailed description of request. getparameternames () and request. getparametervalues () in JSP

Source: Internet
Author: User

The request. getparameternames () method obtains (including buttons) All form objects with name attributes in the Form on the sending request page. An Enumeration type enumeration is returned.

Traverse through the hasmoreelements () method of enumeration. Obtain the enumerated value by the nextelement () method. The value is the value of the name attribute of all controls in form.

Finally, the value of the Form Control is obtained through the request. getparameter () method.

Enumeration pnames = request. getparameternames ();
While (pnames. hasmoreelements ()){
String name = (string) pnames. nextelement ();
String value = request. getparameter (name );
Out. Print (name + "=" + value );
}

The request. getparametervalues ("name") method obtains the value of "name" in all form forms. This method returns an array. You can retrieve the value by traversing the array.

String values = request. getparametervalues ("name ");
For (string value: values ){
System. Out. println (value );
}

Request. getparameternames () values are unordered. Request. getparametervalues () is arranged in the control order of the from form.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.