简体   繁体   English

如何为单个URL参数传递多个值?

[英]How to pass multiple values for a single URL parameter?

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. 我想要做的是后端期望输入参数urls具有一个或多个值。 It can me set to a single or multiple URLs. 它可以设置为单个或多个URL。 What is a way to set the urls parameter so it can have multiple values? 有什么方法可以设置urls参数,使其具有多个值? I can't use my own separator because it can be part of the value itself. 我不能使用自己的分隔符,因为它可以是值本身的一部分。

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 ... . urls参数只能设置为http://google.com或者可以设置为http://google.com http://yahoo.com ... In the backend, I want to process each url as a separate values. 在后端,我想将每个url作为单独的值处理。

http://.../?urls=foo&urls=bar&...

...

request.GET.getlist('urls')

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列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM