Request.getparameter () cannot get a value

Source: Internet
Author: User

    When you debug the sink interface, the received parameter is returned with Request.getparameter (), and the value obtained is null.

The search data says this is related to the attribute enctype of the form form. when the form form content is enctype=multipart/form-data encoded,

The call to Request.getparameter () does not get data. Data can be obtained by Request.getinputstream () and the

"usrcustid=6000060003271506, Bgreturl=http%3a%2f%2f218.241.185.188%3a59999%2fsrd%2fviews%2fregister%2fuserregister "

Formatted data into a string, the string is converted into a map data can be evaluated.

String string = Ioutils.tostring (Request.getinputstream ());
map<string, string> maprequest = URLRequest (String);

Public map<string, String> urlrequest (string string) {
map<string, string> maprequest = new hashmap<string, string> ();
String[] Arrsplit=string.split ("[&]");
for (String strsplit:arrsplit)
{
String[] Arrsplitequal=null;
Arrsplitequal= strsplit.split ("[=]");

Parse out key values
if (arrsplitequal.length>1)
{
Correct parsing
Maprequest.put (Arrsplitequal[0], arrsplitequal[1]);

}
Else
{
if (arrsplitequal[0]!= "")
{
Only parameters have no value, do not join
Maprequest.put (Arrsplitequal[0], "");
}
}
}
return maprequest;
}

Request.getparameter () cannot get a value

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.