Package org.springframework.web.service.invoker

# Class RequestParamArgumentResolver

java.lang.Object
org.springframework.web.service.invoker.AbstractNamedValueArgumentResolver
org.springframework.web.service.invoker.RequestParamArgumentResolver

All Implemented Interfaces:
  `HttpServiceArgumentResolver`

public class RequestParamArgumentResolver extends AbstractNamedValueArgumentResolver
`HttpServiceArgumentResolver` for `@RequestParam` annotated arguments.

When `"content-type"` is set to `"application/x-www-form-urlencoded"`, request parameters are encoded in the request body. Otherwise, they are added as URL query parameters.

The argument may be:

- `Map<String, ?>` or `MultiValueMap<String, ?>` with multiple request parameter and value(s).
- `Collection` or an array of request parameters.
- An individual request parameter.

Individual request parameters may be Strings or Objects to be converted to String values through the configured `ConversionService`.

If the value is required but `null`, `IllegalArgumentException` is raised. The value is not required if:

- `RequestParam.required()` is set to `false`
- `RequestParam.defaultValue()` provides a fallback value
- The argument is declared as `Optional`

Since:
  6.0
Author:
  Rossen Stoyanchev

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.web.service.invoker.AbstractNamedValueArgumentResolver

`AbstractNamedValueArgumentResolver.NamedValueInfo`

## Field Summary

### Fields inherited from class org.springframework.web.service.invoker.AbstractNamedValueArgumentResolver

`logger`

## Constructor Summary

Constructors
Constructor
Description
`RequestParamArgumentResolver(org.springframework.core.convert.ConversionService conversionService)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addRequestValue(String name, Object value, org.springframework.core.MethodParameter parameter, HttpRequestValues.Builder requestValues)`
Add the given, single request value.
`protected AbstractNamedValueArgumentResolver.NamedValueInfo`
`createNamedValueInfo(org.springframework.core.MethodParameter parameter)`
Return information about the request value, or `null` if the parameter does not represent a request value of interest.
`protected AbstractNamedValueArgumentResolver.NamedValueInfo`
`createNamedValueInfo(org.springframework.core.MethodParameter parameter, HttpRequestValues.Metadata metadata)`
Variant of `AbstractNamedValueArgumentResolver.createNamedValueInfo(MethodParameter)` that also provides access to the static values set from `@HttpExchange` attributes.
`boolean`
`isFavorSingleValue()`
Return the setting for `favorSingleValue`.
`protected boolean`
`isFormOrMultipartContent(HttpRequestValues.Metadata metadata)`
Whether the content type is form data, or it is a multipart request.
`void`
`setFavorSingleValue(boolean favorSingleValue)`
Whether to format multiple values (for example, collection, array) as a single String value through the configured `ConversionService` unless the content type is form data, or it is a multipart request.
`protected boolean`
`supportsMultipleValues(org.springframework.core.MethodParameter parameter, HttpRequestValues.Metadata metadata)`
Determine whether the resolver should send multi-value request parameters as individual values.

### Methods inherited from class org.springframework.web.service.invoker.AbstractNamedValueArgumentResolver

`resolve`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### RequestParamArgumentResolver

public RequestParamArgumentResolver(org.springframework.core.convert.ConversionService conversionService)

## Method Details

### setFavorSingleValue

public void setFavorSingleValue(boolean favorSingleValue)
Whether to format multiple values (for example, collection, array) as a single String value through the configured `ConversionService` unless the content type is form data, or it is a multipart request.

By default, this is `false` in which case formatting is not applied, and a separate parameter with the same name is created for each value.

Since:
  6.2

### isFavorSingleValue

public boolean isFavorSingleValue()
Return the setting for `favorSingleValue`.

Since:
  6.2

### createNamedValueInfo

@Nullable protected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter, HttpRequestValues.Metadata metadata)
Description copied from class: `AbstractNamedValueArgumentResolver`
Variant of `AbstractNamedValueArgumentResolver.createNamedValueInfo(MethodParameter)` that also provides access to the static values set from `@HttpExchange` attributes.

Overrides:
  `createNamedValueInfo` in class `AbstractNamedValueArgumentResolver`

### createNamedValueInfo

protected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(org.springframework.core.MethodParameter parameter)
Description copied from class: `AbstractNamedValueArgumentResolver`
Return information about the request value, or `null` if the parameter does not represent a request value of interest.

Specified by:
  `createNamedValueInfo` in class `AbstractNamedValueArgumentResolver`

### supportsMultipleValues

protected boolean supportsMultipleValues(org.springframework.core.MethodParameter parameter, HttpRequestValues.Metadata metadata)
Determine whether the resolver should send multi-value request parameters as individual values. If not, they are formatted to a single String value. The default implementation uses `isFavorSingleValue()` to decide unless the content type is form data, or it is a multipart request.

Since:
  6.2

### isFormOrMultipartContent

protected boolean isFormOrMultipartContent(HttpRequestValues.Metadata metadata)
Whether the content type is form data, or it is a multipart request.

Since:
  6.2

### addRequestValue

protected void addRequestValue(String name, Object value, org.springframework.core.MethodParameter parameter, HttpRequestValues.Builder requestValues)
Description copied from class: `AbstractNamedValueArgumentResolver`
Add the given, single request value. This may be called multiples times if the request value is multivalued.

If the resolver was created with a `ConversionService`, the value will have been converted to a String and may be cast down.

Specified by:
  `addRequestValue` in class `AbstractNamedValueArgumentResolver`
Parameters:
  `name` - the request value name
  `value` - the value
  `parameter` - the method parameter type, nested if Map, List/array, or Optional
  `requestValues` - builder to add the request value to