本文整理汇总了Java中org.springframework.web.bind.annotation.RequestMapping.consumes方法的典型用法代码示例。如果您正苦于以下问题:Java RequestMapping.consumes方法的具体用法?Java RequestMapping.consumes怎么用?Java RequestMapping.consumes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.bind.annotation.RequestMapping
的用法示例。
在下文中一共展示了RequestMapping.consumes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logFunctionArguments
import org.springframework.web.bind.annotation.RequestMapping; //导入方法依赖的package包/类
/**
* Generated name-value pair of method's formal arguments. Appends the generated string in provided StringBuilder
*
* @param argNames String[] containing method's formal argument names Order of names must correspond to order on arg
* values in argValues.
* @param argValues String[] containing method's formal argument values. Order of values must correspond to order on
* arg names in argNames.
* @param stringBuilder the StringBuilder to append argument data to.
*/
private void logFunctionArguments(
@Nonnull String[] argNames,
@Nonnull Object[] argValues,
@Nonnull StringBuilder stringBuilder,
@Nonnull Annotation annotations[][],
@Nullable RequestMapping methodRequestMapping) {
boolean someArgNeedsSerialization = false;
if (methodRequestMapping != null) {
for (String consumes : methodRequestMapping.consumes()) {
if (consumes.equals(MediaType.APPLICATION_JSON_VALUE)) {
someArgNeedsSerialization = true;
break;
}
}
}
stringBuilder.append(" called with arguments: ");
for (int i = 0, length = argNames.length; i < length; ++i) {
boolean needsSerialization = false;
if (someArgNeedsSerialization) {
// We only need to serialize a param if @RequestBody annotation is found.
for (Annotation annotation : annotations[i]) {
if (annotation instanceof RequestBody) {
needsSerialization = true;
break;
}
}
}
stringBuilder.append(argNames[i]).append(": [");
if (needsSerialization) {
String argClassName = argValues[i] == null ? "NULL" : argValues[i].getClass().getName();
serialize(argValues[i], argClassName, stringBuilder);
} else {
stringBuilder.append(argValues[i]);
}
stringBuilder.append("]").append(i == (length - 1) ? "" : ", ");
}
}