Java-jsp the request of the built-in object to get a map that encapsulates all parameter values

Source: Internet
Author: User
Tags java web

Related information:
"21-Day Learning Java Web Development"

Get a map that encapsulates all parameter values
1. Obtain the map object that encapsulates all the parameter values by using the Getparametermap () method of the Request object.
2. The Map object allows you to obtain the parameter values for the specified parameter.

requestform5.jsp

1 <%@ Page Language="Java"ContentType="text/html;charset=gb2312" %>2 <HTML>3 <Head>4   <title>Form</title>5 </Head>6 <Body>7   <formAction= "requestdemo5.jsp"Method= "POST">8User name:<inputtype= "text"name= "username"/><BR>9User password:<inputtype= "Password"name= "UserPassword"/><BR>Ten Favorite Sports: One     <inputtype= "checkbox"name= "Sport"value= "Pingpang">Table Tennis A     <inputtype= "checkbox"name= "Sport"value= "Badketball">Basketball -     <inputtype= "checkbox"name= "Sport"value= "Football">Football<BR> -     <inputtype= "Submit"value= "Submit"> the   </form> - </Body> - </HTML>
View Code

requestdemo5.jsp

1 <%@ Page Language="Java"ContentType="text/html;charset=gb2312"Import="java.util.*" %>2 <HTML>3 <Head>4   <title>Use the Request object to get a map that encapsulates all parameter values</title>5 </Head>6 <Body>7   <%--A map that encapsulates all parameter values through the Getparametermap of the request object--%>  8   <% 9 Map<String, String[]>Mapparamter=Request.getparametermap ();//a map with parameter values for a sealed deviceTen     String[] strUserName= (String[]) Mapparamter.get ("username");//get the username parameter value One Out.println ("User name:"+strusername[0]+"<br>");//Print output username parameter values A     String[] strpassword= (String[]) Mapparamter.get ("UserPassword");//get Suerpassword parameter value - Out.println ("User password:"+strpassword[0]+"<br>");//print output UserPassword parameter values -     String[] Strsport= (String[]) Mapparamter.get ("Sport");//get the sport parameter values the Out.println ("Favorite Sports:"); -      for(StringSport:strsport) { - out.println (sport);//traverse Print Output Sport parameter values -     }     +   %> - </Body> + </HTML>
View Code

Java-jsp the request of the built-in object to get a map that encapsulates all parameter values

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.