1. What is a multi-valued query parameter in a URL?
Why: A multi-valued query parameter repeats the same name with different values, for example /test?x=value1&x=value2&x=value3.
2. Which URL has a multi-valued query parameter?
Why: Only the first URL repeats the same name x in the query string. The other URLs use different names, path segments or a fragment.
3. Which Spring MVC annotation is used to map query parameters, including multi-valued ones, to handler method parameters?
Why:@RequestParam binds URL query parameters to handler method parameters. It also works when the parameter has multiple values.
4. Which handler method parameter types can hold all the values of a multi-valued query parameter?
Why: Multiple values can be mapped to an array or a List. A single simple value cannot hold several values.
5. Which handler method parameter correctly receives all values of x from /test?x=a&x=b?
Why:@RequestParam reads query parameters and can map repeated values to an array. The other annotations read different parts of the request, or do not take a name like this.
6. For the URL /test?x=a&x=b&x=c, what does a List parameter mapped to x contain?
Why: Each repeated value becomes one element of the list, in the same order as in the URL.
7. Can the elements of the array or list be of a type other than String?
Why: Spring converts each value to the element type. So you can use arrays or lists of String or other supported types like int or Integer.
8. A handler method has this parameter. The URL is /test?id=1&id=2. What happens to the values?
@RequestParam("id") int[] ids
Why: Spring converts every value to int and puts all of them in the array.
9. In @RequestParam("x"), what does "x" refer to?
Why: The value in @RequestParam is the name of the query parameter to read from the request URL.
10. Which Spring type can hold all query parameters together, where each name maps to a list of values?
Why:MultiValueMap stores several values for each key. It can be used with @RequestParam to receive multi-valued query parameters.
11. When @RequestParam is used with a MultiValueMap parameter, what does the map contain?
Why: A MultiValueMap parameter with @RequestParam receives all request parameters. Each name is a key and its values are kept in a list.
12. In a MultiValueMap that holds query parameters, what type of object do you get when you read the values of one parameter name?
Why: Each key maps to a list of values, so reading one parameter name gives you all of its values as a list.