@MatrixVariable resolvers for WebFlux

The information was already parsed and available in a request attribute
but until now there were no argument resolvers to expose it.

Issue: SPR-16005
This commit is contained in:
Rossen Stoyanchev
2017-10-19 21:01:38 -04:00
parent c7a15260d6
commit ab92754a2e
14 changed files with 865 additions and 136 deletions

View File

@@ -38,9 +38,13 @@ import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.servlet.HandlerMapping;
/**
* Resolves method arguments of type Map annotated with
* {@link MatrixVariable @MatrixVariable} where the annotation does not
* specify a name. If a name is specified then the argument will by resolved by the
* Resolves arguments of type {@link Map} annotated with {@link MatrixVariable
* @MatrixVariable} where the annotation does not specify a name. In other words
* the purpose of this resolver is to provide access to multiple matrix
* variables, either all or associted with a specific path variable.
*
* <p>When a name is specified, an argument of type Map is considered to be an
* single attribute with a Map value, and is resolved by
* {@link MatrixVariableMethodArgumentResolver} instead.
*
* @author Rossen Stoyanchev
@@ -48,6 +52,7 @@ import org.springframework.web.servlet.HandlerMapping;
*/
public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.class);

View File

@@ -35,10 +35,12 @@ import org.springframework.web.method.annotation.AbstractNamedValueMethodArgumen
import org.springframework.web.servlet.HandlerMapping;
/**
* Resolves method arguments annotated with {@link MatrixVariable @MatrixVariable}.
* Resolves arguments annotated with {@link MatrixVariable @MatrixVariable}.
*
* <p>If the method parameter is of type Map and no name is specified, then it will
* by resolved by the {@link MatrixVariableMapMethodArgumentResolver} instead.
* <p>If the method parameter is of type {@link Map} it will by resolved by
* {@link MatrixVariableMapMethodArgumentResolver} instead unless the annotation
* specifies a name in which case it is considered to be a single attribute of
* type map (vs multiple attributes collected in a map).
*
* @author Rossen Stoyanchev
* @author Sam Brannen