Difference between revisions of "Specifying Parameters in a URL"
imported>Aeric |
imported>Aeric m (Text replace - '{domain}' to '{{domain}}') |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
A ''parameter list'' is appended to a URI after a "?". Multiple parameters are separated by "&", as shown here: | A ''parameter list'' is appended to a URI after a "?". Multiple parameters are separated by "&", as shown here: | ||
:<syntaxhighlight lang="vbnet"> | :<syntaxhighlight lang="vbnet"> | ||
https://{domain}/networking/{targetAddress}?parameterName1=value1¶meterName2=value2 | https://{{domain}}/networking/{targetAddress}?parameterName1=value1¶meterName2=value2 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
For boolean arguments, the value passed can be "1" or "true", "0" or "false". | For boolean arguments, the value passed can be "1" or "true", "0" or "false". | ||
{{:URL Encoding}} | {{:URL Encoding}} |
Latest revision as of 19:21, 25 April 2014
You pass arguments in a URL using query parameters. Those parameters are specified in the form parameterName=value.
A parameter list is appended to a URI after a "?". Multiple parameters are separated by "&", as shown here:
https://{{domain}}/networking/{targetAddress}?parameterName1=value1¶meterName2=value2
For boolean arguments, the value passed can be "1" or "true", "0" or "false".
Note:
When specifying a URL in code, any special characters (characters other than letters and numbers) need to be encoded. For example, a space character can be encoded using either + or %20.(Browsers typically take care of encoding URLs entered into the address bar--so the URL displayed after visiting a page may differ somewhat from the one that was initially entered.)
Here are some typical encodings:
space
+
%%20 or +
%2B
%25
So:
Instead of Use & (A&B)
space (A B)%26 (A%26B)
%20 (A%20B)
It can be hard to get be hard to get the encoding right, so it's desirable to use a language library designed for the purpose.
Learn more:- URL Encoding in HTML
- Encode a URL in JavaScript
- URLEncoder class for Java