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() . These examples are extracted from open source projects. 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
@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 2
@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
@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 4
/**
 * 根据方法和传入的参数获取请求参数
 */
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 5
Source Project: macrozheng-mall   File: WebLogAspect.java    License: 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 6
Source Project: mall-tiny   File: WebLogAspect.java    License: 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 7
Source Project: HIS   File: WebLogAspect.java    License: 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 8
Source Project: HIS   File: WebLogAspect.java    License: 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 9
Source Project: HIS   File: WebLogAspect.java    License: 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 10
Source Project: HIS   File: WebLogAspect.java    License: 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 11
Source Project: HIS   File: WebLogAspect.java    License: 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 Project: HIS   File: WebLogAspect.java    License: 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 Project: springdoc-openapi   File: ParameterInfo.java    License: 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 14
Source Project: mall-learning   File: WebLogAspect.java    License: 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 15
Source Project: mall-learning   File: WebLogAspect.java    License: 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 16
Source Project: mall-learning   File: WebLogAspect.java    License: 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 17
Source Project: mall-swarm   File: WebLogAspect.java    License: 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 Project: macrozheng   File: WebLogAspect.java    License: 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 19
Source Project: mall   File: WebLogAspect.java    License: 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 20
public RequestParamNamedValueInfo(RequestParam annotation) {
    super((annotation.name() != null && annotation.name() != "") ? annotation.name() : annotation.value(),
        annotation.required(), annotation.defaultValue());

}