Java Code Examples for org.springframework.web.bind.annotation.RequestParam#value()

The following examples show how to use org.springframework.web.bind.annotation.RequestParam#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestParamParameterProcessor.java    From spring-cloud-openfeign with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processArgument(AnnotatedParameterContext context,
		Annotation annotation, Method method) {
	int parameterIndex = context.getParameterIndex();
	Class<?> parameterType = method.getParameterTypes()[parameterIndex];
	MethodMetadata data = context.getMethodMetadata();

	if (Map.class.isAssignableFrom(parameterType)) {
		checkState(data.queryMapIndex() == null,
				"Query map can only be present once.");
		data.queryMapIndex(parameterIndex);

		return true;
	}

	RequestParam requestParam = ANNOTATION.cast(annotation);
	String name = requestParam.value();
	checkState(emptyToNull(name) != null,
			"RequestParam.value() was empty on parameter %s", parameterIndex);
	context.setParameterName(name);

	Collection<String> query = context.setTemplateParameter(name,
			data.template().queries().get(name));
	data.template().query(name, query);
	return true;
}
 
Example 2
Source File: RequestParamParameterProcessor.java    From raptor with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
    int parameterIndex = context.getParameterIndex();
    Class<?> parameterType = method.getParameterTypes()[parameterIndex];
    MethodMetadata data = context.getMethodMetadata();

    if (Map.class.isAssignableFrom(parameterType)) {
        checkState(data.queryMapIndex() == null, "Query map can only be present once.");
        data.queryMapIndex(parameterIndex);

        return true;
    }

    RequestParam requestParam = ANNOTATION.cast(annotation);
    String name = requestParam.value();
    checkState(emptyToNull(name) != null,
            "RequestParam.value() was empty on parameter %s",
            parameterIndex);
    context.setParameterName(name);

    Collection<String> query = context.setTemplateParameter(name,
            data.template().queries().get(name));
    data.template().query(name, query);
    return true;
}
 
Example 3
Source File: RequestParamAnnotationProcessor.java    From servicecomb-toolkit with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example 4
Source File: ParameterInfo.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
/**
 * Calculate name string.
 *
 * @param pName the p name
 * @param requestHeader the request header
 * @param requestParam the request param
 * @param pathVar the path var
 * @param cookieValue the cookie value
 * @return the string
 */
private String calculateName(String pName, RequestHeader requestHeader, RequestParam requestParam, PathVariable pathVar, CookieValue cookieValue) {
	String name = pName;
	if (requestHeader != null && StringUtils.isNotEmpty(requestHeader.value()))
		name = requestHeader.value();
	else if (requestParam != null && StringUtils.isNotEmpty(requestParam.value()))
		name = requestParam.value();
	else if (pathVar != null && StringUtils.isNotEmpty(pathVar.value()))
		name = pathVar.value();
	else if (cookieValue != null && StringUtils.isNotEmpty(cookieValue.value()))
		name = cookieValue.value();
	return name;
}
 
Example 5
Source File: WebLogAspect.java    From mall with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 6
Source File: WebLogAspect.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 7
Source File: WebLogAspect.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 8
Source File: WebLogAspect.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 9
Source File: WebLogAspect.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 10
Source File: WebLogAspect.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 11
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 12
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 13
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 14
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 15
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 16
Source File: WebLogAspect.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 17
Source File: WebLogAspect.java    From mall-tiny with Apache License 2.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 18
Source File: WebLogAspect.java    From macrozheng-mall with MIT License 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 19
Source File: WebLogAspect.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 根据方法和传入的参数获取请求参数
 */
private Object getParameter(Method method, Object[] args) {
    List<Object> argList = new ArrayList<>();
    Parameter[] parameters = method.getParameters();
    for (int i = 0; i < parameters.length; i++) {
        //将RequestBody注解修饰的参数作为请求参数
        RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
        if (requestBody != null) {
            argList.add(args[i]);
        }
        //将RequestParam注解修饰的参数作为请求参数
        RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
        if (requestParam != null) {
            Map<String, Object> map = new HashMap<>();
            String key = parameters[i].getName();
            if (!StringUtils.isEmpty(requestParam.value())) {
                key = requestParam.value();
            }
            map.put(key, args[i]);
            argList.add(map);
        }
    }
    if (argList.size() == 0) {
        return null;
    } else if (argList.size() == 1) {
        return argList.get(0);
    } else {
        return argList;
    }
}
 
Example 20
Source File: OpenFeignApplictionInitalizer.java    From summerframework with Apache License 2.0 4 votes vote down vote up
public RequestParamNamedValueInfo(RequestParam annotation) {
    super((annotation.name() != null && annotation.name() != "") ? annotation.name() : annotation.value(),
        annotation.required(), annotation.defaultValue());

}