Separate multiple parameters with commas (,).

Source: Internet
Author: User
Problem:What delimiters should be used to connect a list parameter? For example:
1. The get method has the key1 parameter. Its corresponding value is a list and its value is value1 and value2. What delimiters are used to connect the two value values. 2. In the configuration file, the value is also a list. How can we splice it? 3. What Delimiter is used to save the list as a DB field?
Conclusion: Use commas as the separator. That is, in the configuration file, it is key = value, value2; In the get method, the URL is http: // host/Key = value1, value2 & otherkey = value3; DB field value Key = value1, value2
The specific reasons are as follows:
1. First, we will discuss the second case. If it is a configuration file, we recommend that you use the "," separator for the Apache commons-configuration package to help us read the configuration file. It contains a getlist method, which can convert the value to a list. The default value Delimiter is ",". For example, if the configuration file contains name = harryli and ponyma, a list type can be directly returned through getlist ("names, this makes it easier for us to perform subsequent operations. If Apache uses "," as the separator, it must be refined. If this specification is followed, we can also directly use the getlist method.
2. Let's discuss the first case. There are three candidates: "+", ";", "and" + ", which are special characters in the URL. If the parameter is a plus sign, it is converted into a space. Therefore, the + sign ";" cannot be used. In W3C specifications, the ";" can be the same as "&" and used as a connector between parameters, for example, http: // host /? X = 1 & Y = 2 is equivalent to http: // host /? X = 1; y = 2. Since it has this meaning, we cannot use ";" as the parameter content separator "." There is no concern about semicolons. We also recommend that you use ", "As a separator. Therefore, we also recommend that you use", "(comma) as the separator of the parameter content for the get method.
3. Next we will discuss the third case. For the database, it is also saved as a comma, because MySQL has a find_in_set method that can search for the STR concatenated by commas (,). For example, if the field value str_list is '1, 2, 3 ', find_in_set ('2', str_list) can match this data, because after the field '1, 2, 3' is separated by commas, is a list with three values, including 2.
In conclusion, commas are generally used as separators.


Separate multiple parameters with commas (,).

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.