org.springframework.web.bind.annotation.ValueConstants源码实例Demo

类org.springframework.web.bind.annotation.ValueConstants源码实例Demo

下面列出了怎么用org.springframework.web.bind.annotation.ValueConstants的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public void process(RequestParam requestParam, ParameterContext parameterContext) {

  parameterContext.setIn(InType.QUERY);
  String name = requestParam.value();
  if (StringUtils.isEmpty(name)) {
    name = requestParam.name();
  }

  parameterContext.setName(name);
  parameterContext.setRequired(requestParam.required());
  if (!ObjectUtils.isEmpty(requestParam.defaultValue()) && !ValueConstants.DEFAULT_NONE
      .equals(requestParam.defaultValue())) {
    parameterContext.setDefaultValue(requestParam.defaultValue());
    parameterContext.setRequired(false);
  }
}
 
@Override
public void process(RequestHeader requestHeader, ParameterContext parameterContext) {
  parameterContext.setIn(InType.HEADER);
  parameterContext.setRequired(requestHeader.required());

  if (!ObjectUtils.isEmpty(requestHeader.defaultValue()) && !ValueConstants.DEFAULT_NONE
      .equals(requestHeader.defaultValue())) {
    parameterContext.setDefaultValue(requestHeader.defaultValue());
  }

  String name = requestHeader.name();
  if (StringUtils.isEmpty(name)) {
    name = requestHeader.value();
  }

  parameterContext.setName(name);
}
 
/**
 * Build param parameter.
 *
 * @param parameterInfo the parameter info
 * @param components the components
 * @param requestInfo the request info
 * @param jsonView the json view
 * @return the parameter
 */
private Parameter buildParam(ParameterInfo parameterInfo, Components components, RequestInfo requestInfo,
		JsonView jsonView) {
	Parameter parameter;
	String pName = parameterInfo.getpName();
	String name = StringUtils.isBlank(requestInfo.value()) ? pName : requestInfo.value();
	parameterInfo.setpName(name);

	if (!ValueConstants.DEFAULT_NONE.equals(requestInfo.defaultValue()))
		parameter = this.buildParam(requestInfo.type(), components, parameterInfo, false,
				requestInfo.defaultValue(), jsonView);
	else
		parameter = this.buildParam(requestInfo.type(), components, parameterInfo, requestInfo.required(), null,
				jsonView);
	return parameter;
}
 
源代码4 项目: FastBootWeixin   文件: WxApiParamContributor.java
@Override
public void contributeMethodArgument(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
    Class<?> paramType = parameter.getNestedParameterType();
    if (Map.class.isAssignableFrom(paramType)) {
        return;
    }
    WxApiParam wxApiParam = parameter.getParameterAnnotation(WxApiParam.class);
    String name = (wxApiParam == null || StringUtils.isEmpty(wxApiParam.name()) ? parameter.getParameterName() : wxApiParam.name());
    WxAppAssert.notNull(name, "请添加编译器的-parameter或者为参数添加注解名称");
    if (value == null) {
        if (wxApiParam != null) {
            if (!wxApiParam.required() || !wxApiParam.defaultValue().equals(ValueConstants.DEFAULT_NONE)) {
                return;
            }
        }
        builder.queryParam(name);
    } else if (value instanceof Collection) {
        for (Object element : (Collection<?>) value) {
            element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
            builder.queryParam(name, element);
        }
    } else {
        builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
    }
}
 
@Nullable
@Override
public Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext,
		ServerWebExchange exchange) {

	Map<String, MultiValueMap<String, String>> matrixVariables =
			exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE);

	if (CollectionUtils.isEmpty(matrixVariables)) {
		return Collections.emptyMap();
	}

	MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
	MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class);
	Assert.state(annotation != null, "No MatrixVariable annotation");
	String pathVariable = annotation.pathVar();

	if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) {
		MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable);
		if (mapForPathVariable == null) {
			return Collections.emptyMap();
		}
		map.putAll(mapForPathVariable);
	}
	else {
		for (MultiValueMap<String, String> vars : matrixVariables.values()) {
			vars.forEach((name, values) -> {
				for (String value : values) {
					map.add(name, value);
				}
			});
		}
	}

	return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map);
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with
 * sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.isEmpty()) {
		name = parameter.getParameterName();
		if (name == null) {
			String type = parameter.getNestedParameterType().getName();
			throw new IllegalArgumentException("Name for argument type [" + type + "] not " +
					"available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
		NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception {

	@SuppressWarnings("unchecked")
	Map<String, MultiValueMap<String, String>> matrixVariables =
			(Map<String, MultiValueMap<String, String>>) request.getAttribute(
					HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

	if (CollectionUtils.isEmpty(matrixVariables)) {
		return Collections.emptyMap();
	}

	MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
	MatrixVariable ann = parameter.getParameterAnnotation(MatrixVariable.class);
	Assert.state(ann != null, "No MatrixVariable annotation");
	String pathVariable = ann.pathVar();

	if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) {
		MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable);
		if (mapForPathVariable == null) {
			return Collections.emptyMap();
		}
		map.putAll(mapForPathVariable);
	}
	else {
		for (MultiValueMap<String, String> vars : matrixVariables.values()) {
			vars.forEach((name, values) -> {
				for (String value : values) {
					map.add(name, value);
				}
			});
		}
	}

	return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map);
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.isEmpty()) {
		name = parameter.getParameterName();
		if (name == null) {
			throw new IllegalArgumentException(
					"Name for argument type [" + parameter.getNestedParameterType().getName() +
					"] not available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
@Override
public void contributeMethodArgument(MethodParameter parameter, @Nullable Object value,
		UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {

	Class<?> paramType = parameter.getNestedParameterType();
	if (Map.class.isAssignableFrom(paramType) || MultipartFile.class == paramType || Part.class == paramType) {
		return;
	}

	RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.class);
	String name = (requestParam != null && StringUtils.hasLength(requestParam.name()) ?
			requestParam.name() : parameter.getParameterName());
	Assert.state(name != null, "Unresolvable parameter name");

	parameter = parameter.nestedIfOptional();
	if (value instanceof Optional) {
		value = ((Optional<?>) value).orElse(null);
	}

	if (value == null) {
		if (requestParam != null &&
				(!requestParam.required() || !requestParam.defaultValue().equals(ValueConstants.DEFAULT_NONE))) {
			return;
		}
		builder.queryParam(name);
	}
	else if (value instanceof Collection) {
		for (Object element : (Collection<?>) value) {
			element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
			builder.queryParam(name, element);
		}
	}
	else {
		builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
	}
}
 
@Nullable
@Override
public Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext,
		ServerWebExchange exchange) {

	Map<String, MultiValueMap<String, String>> matrixVariables =
			exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE);

	if (CollectionUtils.isEmpty(matrixVariables)) {
		return Collections.emptyMap();
	}

	MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
	MatrixVariable annotation = parameter.getParameterAnnotation(MatrixVariable.class);
	Assert.state(annotation != null, "No MatrixVariable annotation");
	String pathVariable = annotation.pathVar();

	if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) {
		MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable);
		if (mapForPathVariable == null) {
			return Collections.emptyMap();
		}
		map.putAll(mapForPathVariable);
	}
	else {
		for (MultiValueMap<String, String> vars : matrixVariables.values()) {
			vars.forEach((name, values) -> {
				for (String value : values) {
					map.add(name, value);
				}
			});
		}
	}

	return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map);
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with
 * sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.isEmpty()) {
		name = parameter.getParameterName();
		if (name == null) {
			String type = parameter.getNestedParameterType().getName();
			throw new IllegalArgumentException("Name for argument type [" + type + "] not " +
					"available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
		NativeWebRequest request, @Nullable WebDataBinderFactory binderFactory) throws Exception {

	@SuppressWarnings("unchecked")
	Map<String, MultiValueMap<String, String>> matrixVariables =
			(Map<String, MultiValueMap<String, String>>) request.getAttribute(
					HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

	if (CollectionUtils.isEmpty(matrixVariables)) {
		return Collections.emptyMap();
	}

	MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
	MatrixVariable ann = parameter.getParameterAnnotation(MatrixVariable.class);
	Assert.state(ann != null, "No MatrixVariable annotation");
	String pathVariable = ann.pathVar();

	if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) {
		MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable);
		if (mapForPathVariable == null) {
			return Collections.emptyMap();
		}
		map.putAll(mapForPathVariable);
	}
	else {
		for (MultiValueMap<String, String> vars : matrixVariables.values()) {
			vars.forEach((name, values) -> {
				for (String value : values) {
					map.add(name, value);
				}
			});
		}
	}

	return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map);
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.isEmpty()) {
		name = parameter.getParameterName();
		if (name == null) {
			throw new IllegalArgumentException(
					"Name for argument type [" + parameter.getNestedParameterType().getName() +
					"] not available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
@Override
public void contributeMethodArgument(MethodParameter parameter, @Nullable Object value,
		UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {

	Class<?> paramType = parameter.getNestedParameterType();
	if (Map.class.isAssignableFrom(paramType) || MultipartFile.class == paramType || Part.class == paramType) {
		return;
	}

	RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.class);
	String name = (requestParam == null || StringUtils.isEmpty(requestParam.name()) ?
			parameter.getParameterName() : requestParam.name());
	Assert.state(name != null, "Unresolvable parameter name");

	if (value == null) {
		if (requestParam != null &&
				(!requestParam.required() || !requestParam.defaultValue().equals(ValueConstants.DEFAULT_NONE))) {
			return;
		}
		builder.queryParam(name);
	}
	else if (value instanceof Collection) {
		for (Object element : (Collection<?>) value) {
			element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
			builder.queryParam(name, element);
		}
	}
	else {
		builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
	}
}
 
源代码15 项目: choerodon-starters   文件: PropertyJobParam.java
PropertyJobParam(final JobParam jobParam) {
    this.name = jobParam.name();
    this.type = getParamTypeByClass(jobParam.type()).getValue();
    if (!ValueConstants.DEFAULT_NONE.equals(jobParam.defaultValue())) {
        try {
            this.defaultValue = jobParam.type().getConstructor(String.class).newInstance(jobParam.defaultValue());
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            throw new JobParamDefaultValueParseException(e, jobParam.type(), jobParam.defaultValue());
        }

    }
    this.description = jobParam.description();
}
 
@Override
protected String readDefaultValue(ANNOTATION annotation) {
  String defaultValue = pureReadDefaultValue(annotation);
  if (StringUtils.isEmpty(defaultValue) || defaultValue.equals(ValueConstants.DEFAULT_NONE)) {
    return "";
  }
  return defaultValue;
}
 
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest request, WebDataBinderFactory binderFactory) throws Exception {

	@SuppressWarnings("unchecked")
	Map<String, MultiValueMap<String, String>> matrixVariables =
			(Map<String, MultiValueMap<String, String>>) request.getAttribute(
					HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

	if (CollectionUtils.isEmpty(matrixVariables)) {
		return Collections.emptyMap();
	}

	MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
	String pathVariable = parameter.getParameterAnnotation(MatrixVariable.class).pathVar();

	if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) {
		MultiValueMap<String, String> mapForPathVariable = matrixVariables.get(pathVariable);
		if (mapForPathVariable == null) {
			return Collections.emptyMap();
		}
		map.putAll(mapForPathVariable);
	}
	else {
		for (MultiValueMap<String, String> vars : matrixVariables.values()) {
			for (String name : vars.keySet()) {
				for (String value : vars.get(name)) {
					map.add(name, value);
				}
			}
		}
	}

	return (isSingleValueMap(parameter) ? map.toSingleValueMap() : map);
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.isEmpty()) {
		name = parameter.getParameterName();
		if (name == null) {
			throw new IllegalArgumentException(
					"Name for argument type [" + parameter.getNestedParameterType().getName() +
					"] not available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
源代码19 项目: lams   文件: RequestParamMethodArgumentResolver.java
@Override
public void contributeMethodArgument(MethodParameter parameter, Object value,
		UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {

	Class<?> paramType = parameter.getNestedParameterType();
	if (Map.class.isAssignableFrom(paramType) || MultipartFile.class == paramType ||
			"javax.servlet.http.Part".equals(paramType.getName())) {
		return;
	}

	RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.class);
	String name = (requestParam == null || StringUtils.isEmpty(requestParam.name()) ?
			parameter.getParameterName() : requestParam.name());

	if (value == null) {
		if (requestParam != null) {
			if (!requestParam.required() || !requestParam.defaultValue().equals(ValueConstants.DEFAULT_NONE)) {
				return;
			}
		}
		builder.queryParam(name);
	}
	else if (value instanceof Collection) {
		for (Object element : (Collection<?>) value) {
			element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
			builder.queryParam(name, element);
		}
	}
	else {
		builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
	}
}
 
源代码20 项目: FastBootWeixin   文件: WxApiMethodInfo.java
private String getMethodWxApiRequestPath(Method method) {
    WxApiRequest wxApiRequest = AnnotatedElementUtils.findMergedAnnotation(method, WxApiRequest.class);
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.path()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.path())) {
        // 默认情况下取方法名为变量名,尝试从环境变量中获取信息
        return WxContextUtils.resolveStringValue("${" + this.wxApiTypeInfo.getPropertyPrefix() + "." + method.getName() + "}");
    }
    return wxApiRequest.path();
}
 
源代码21 项目: FastBootWeixin   文件: WxApiExecutor.java
/**
 * 要发送文件,使用这种方式,请查看源码:FormHttpMessageConverter
 *
 * @param wxApiMethodInfo
 * @param args
 * @return the result
 */
private Object getFormBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    wxApiMethodInfo.getMethodParameters().stream()
            .filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiForm.class) || p.hasParameterAnnotation(WxApiBody.class))
            .forEach(p -> {
                // 为空则直接返回不加这个参数
                if (args[p.getParameterIndex()] == null) {
                    return;
                }
                WxApiForm wxApiForm = p.getParameterAnnotation(WxApiForm.class);
                String paramName;
                Object param;
                if (wxApiForm == null || ValueConstants.DEFAULT_NONE.equals(wxApiForm.value())) {
                    paramName = p.getParameterName();
                } else {
                    paramName = wxApiForm.value();
                }
                // 加入Assert
                WxAppAssert.notNull(paramName, "请添加编译器的-parameter或者为参数添加注解名称");
                if (WxWebUtils.isMutlipart(p.getParameterType())) {
                    param = getFormResource(args[p.getParameterIndex()]);
                } else {
                    param = args[p.getParameterIndex()];
                }
                params.add(paramName, param);
            });
    return params;
}
 
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.length() == 0) {
		name = parameter.getParameterName();
		if (name == null) {
			throw new IllegalArgumentException("Name for argument type [" + parameter.getParameterType().getName() +
					"] not available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
/**
 * Update the contextPath, servletPath, and pathInfo of the request.
 */
private void updatePathRequestProperties(MockHttpServletRequest request, String requestUri) {
	Assert.isTrue(requestUri.startsWith(this.contextPath),
			"requestURI [" + requestUri + "] does not start with contextPath [" + this.contextPath + "]");
	request.setContextPath(this.contextPath);
	request.setServletPath(this.servletPath);
	if (ValueConstants.DEFAULT_NONE.equals(this.pathInfo)) {
		Assert.isTrue(requestUri.startsWith(this.contextPath + this.servletPath),
				"Invalid servletPath [" + this.servletPath + "] for requestURI [" + requestUri + "]");
		String extraPath = requestUri.substring(this.contextPath.length() + this.servletPath.length());
		this.pathInfo = (StringUtils.hasText(extraPath)) ? extraPath : null;
	}
	request.setPathInfo(this.pathInfo);
}
 
源代码24 项目: wadl-tools   文件: ParamFromRequestParamBuilder.java
@Override
public Param build(Method javaMethod, int paramIndex, Annotation paramAnnotation) {
    final RequestParam requestParam = (RequestParam) paramAnnotation;
    final Param param = new Param()
            .withName(discoverParamName(javaMethod, paramIndex, requestParam.value()))
            .withStyle(ParamStyle.QUERY)
            .withRequired(requestParam.required())
            .withType(grammarsDiscoverer.discoverQNameFor(new ClassMetadataFromParam(javaMethod, paramIndex)));

    if (!ValueConstants.DEFAULT_NONE.equals(requestParam.defaultValue())) {
        param.setDefault(requestParam.defaultValue());
    }
    return param;
}
 
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	SessionAttribute ann = parameter.getParameterAnnotation(SessionAttribute.class);
	Assert.state(ann != null, "No SessionAttribute annotation");
	return new NamedValueInfo(ann.name(), ann.required(), ValueConstants.DEFAULT_NONE);
}
 
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	RequestAttribute ann = parameter.getParameterAnnotation(RequestAttribute.class);
	Assert.state(ann != null, "No RequestAttribute annotation");
	return new NamedValueInfo(ann.name(), ann.required(), ValueConstants.DEFAULT_NONE);
}
 
@Nullable
@Override
protected Object resolveNamedValue(String name, MethodParameter param, ServerWebExchange exchange) {
	Map<String, MultiValueMap<String, String>> pathParameters =
			exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE);
	if (CollectionUtils.isEmpty(pathParameters)) {
		return null;
	}

	MatrixVariable ann = param.getParameterAnnotation(MatrixVariable.class);
	Assert.state(ann != null, "No MatrixVariable annotation");
	String pathVar = ann.pathVar();
	List<String> paramValues = null;

	if (!pathVar.equals(ValueConstants.DEFAULT_NONE)) {
		if (pathParameters.containsKey(pathVar)) {
			paramValues = pathParameters.get(pathVar).get(name);
		}
	}
	else {
		boolean found = false;
		paramValues = new ArrayList<>();
		for (MultiValueMap<String, String> params : pathParameters.values()) {
			if (params.containsKey(name)) {
				if (found) {
					String paramType = param.getNestedParameterType().getName();
					throw new ServerErrorException(
							"Found more than one match for URI path parameter '" + name +
							"' for parameter type [" + paramType + "]. Use 'pathVar' attribute to disambiguate.",
							param, null);
				}
				paramValues.addAll(params.get(name));
				found = true;
			}
		}
	}

	if (CollectionUtils.isEmpty(paramValues)) {
		return null;
	}
	else if (paramValues.size() == 1) {
		return paramValues.get(0);
	}
	else {
		return paramValues;
	}
}
 
RequestParamNamedValueInfo() {
	super("", false, ValueConstants.DEFAULT_NONE);
}
 
public PathVariableNamedValueInfo(PathVariable annotation) {
	super(annotation.name(), annotation.required(), ValueConstants.DEFAULT_NONE);
}
 
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	SessionAttribute ann = parameter.getParameterAnnotation(SessionAttribute.class);
	Assert.state(ann != null, "No SessionAttribute annotation");
	return new NamedValueInfo(ann.name(), ann.required(), ValueConstants.DEFAULT_NONE);
}
 
点击广告?(赏赐笔者)
 类方法