application/x-www-form-urlencoded Specifies the post data sent, to be URL encoded, but the previous &,= used in front of the post message, as a parameter, it is not necessary to encode, you can skip directly. For example:
Loginusername=admin&loginpassword=admin¶m={json message}
The previous two && cannot be encoded, otherwise the Java background does not parse the post data properly. Currently there is a URI in the JSON message:
http://192.168.0.225:8080/kms/services/rest/dataInfoService/downloadFileid=00000001/temp001/097_5848300_10488 &token=7a57a5a7ffffffffc1a0316369671314
There is & in the inside, and if URL encoding is not done, the Java background cannot parse the message properly.
As a result, the previous URL encoding function is simply processed
std::string urlencode (const std::string& STR)
{
std::string strtemp = "";
size_t length = Str.length ();
for (size_t i = 0; i < length; i++)
{
/*
The preceding & is used to differentiate multiple parameter key values, cannot be encoded, and subsequent & must be encoded
*/
if (I < && str[i] = = ' & ')
{
strtemp + = Str[i];
Continue
}
if (Isalnum ((unsigned char) str[i]) | |
(Str[i] = = '-') | |
(Str[i] = = ' _ ') | |
(Str[i] = = '. ') ||
(Str[i] = = ' ~ ') | |
(Str[i] = = '))
strtemp + = Str[i];
else if (str[i] = = ")
strtemp + = "+";
Else
{
strtemp + = '% ';
strtemp + = Tohex ((unsigned char) str[i] >> 4);
strtemp + = Tohex ((unsigned char) str[i]% 16);
}
}
return strtemp;
}
50 is a general figure, and for the moment no other general practice is considered
The problem of specifying application/x-www-form-urlencoded in the RESTful interface