Is it possible to pass multiple values for a single URL parameter without using your own separator?
是否可以在不使用自己的分隔符的情况下为单个URL参数传递多个值?
What I want to do is that the backend expects an input parameter urls
to have one or more values. It can me set to a single or multiple URLs. What is a way to set the urls parameter so it can have multiple values? I can't use my own separator because it can be part of the value itself.
我想要做的是后端期望输入参数URL具有一个或多个值。它可以设置为单个或多个URL。有什么方法可以设置urls参数,使其具有多个值?我不能使用自己的分隔符,因为它可以是值本身的一部分。
Example: http://example.com/?urls=[value,value2...]
示例:http://example.com/?urls = [value,value2 ...]
The urls
parameter be set to just http://google.com
or it can be set to http://google.com
http://yahoo.com ...
. In the backend, I want to process each url as a separate values.
urls参数设置为仅限http://google.com,或者可以设置为http://google.com http://yahoo.com ....在后端,我想将每个网址设置为单独的价值观
2 个解决方案
#1
28
http://.../?urls=foo&urls=bar&...
...
...
request.GET.getlist('urls')
#2
7
The following is probably the best way of doing it - ie, don't specify a delimited list of URLs, rather, use the fact you can specify the same param name multiple times, eg:
以下可能是最好的方法 - 即,不指定URL的分隔列表,而是使用您可以多次指定相同的param名称的事实,例如:
http://example.com/?url=http://google.co.uk&url=http://yahoo.com
The URL list be then be used and retrieved via request.GET.getlist('url')
然后通过request.GET.getlist('url')使用和检索URL列表
#1
28
http://.../?urls=foo&urls=bar&...
...
...
request.GET.getlist('urls')
#2
7
The following is probably the best way of doing it - ie, don't specify a delimited list of URLs, rather, use the fact you can specify the same param name multiple times, eg:
以下可能是最好的方法 - 即,不指定URL的分隔列表,而是使用您可以多次指定相同的param名称的事实,例如:
http://example.com/?url=http://google.co.uk&url=http://yahoo.com
The URL list be then be used and retrieved via request.GET.getlist('url')
然后通过request.GET.getlist('url')使用和检索URL列表