当前位置: 首页>>代码示例>>Java>>正文


Java WebArgumentResolver.UNRESOLVED属性代码示例

本文整理汇总了Java中org.springframework.web.bind.support.WebArgumentResolver.UNRESOLVED属性的典型用法代码示例。如果您正苦于以下问题:Java WebArgumentResolver.UNRESOLVED属性的具体用法?Java WebArgumentResolver.UNRESOLVED怎么用?Java WebArgumentResolver.UNRESOLVED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.web.bind.support.WebArgumentResolver的用法示例。


在下文中一共展示了WebArgumentResolver.UNRESOLVED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: supportsParameter

/**
 * Actually resolve the value and check the resolved value is not
 * {@link WebArgumentResolver#UNRESOLVED} absorbing _any_ exceptions.
 */
@Override
public boolean supportsParameter(MethodParameter parameter) {
	try {
		NativeWebRequest webRequest = getWebRequest();
		Object result = this.adaptee.resolveArgument(parameter, webRequest);
		if (result == WebArgumentResolver.UNRESOLVED) {
			return false;
		}
		else {
			return ClassUtils.isAssignableValue(parameter.getParameterType(), result);
		}
	}
	catch (Exception ex) {
		// ignore (see class-level doc)
		logger.debug("Error in checking support for parameter [" + parameter + "], message: " + ex.getMessage());
		return false;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractWebArgumentResolverAdapter.java

示例2: resolveArgument

/**
 * Delegate to the {@link WebArgumentResolver} instance.
 * @exception IllegalStateException if the resolved value is not assignable
 * to the method parameter.
 */
@Override
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	Class<?> paramType = parameter.getParameterType();
	Object result = this.adaptee.resolveArgument(parameter, webRequest);
	if (result == WebArgumentResolver.UNRESOLVED || !ClassUtils.isAssignableValue(paramType, result)) {
		throw new IllegalStateException(
				"Standard argument type [" + paramType.getName() + "] in method " + parameter.getMethod() +
				"resolved to incompatible value of type [" + (result != null ? result.getClass() : null) +
				"]. Consider declaring the argument type in a less specific fashion.");
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractWebArgumentResolverAdapter.java

示例3: resolveHandlerArguments

/**
 * Resolves the arguments for the given method. Delegates to {@link #resolveCommonArgument}.
 */
private Object[] resolveHandlerArguments(Method handlerMethod, Object handler,
		NativeWebRequest webRequest, Exception thrownException) throws Exception {

	Class<?>[] paramTypes = handlerMethod.getParameterTypes();
	Object[] args = new Object[paramTypes.length];
	Class<?> handlerType = handler.getClass();
	for (int i = 0; i < args.length; i++) {
		MethodParameter methodParam = new SynthesizingMethodParameter(handlerMethod, i);
		GenericTypeResolver.resolveParameterType(methodParam, handlerType);
		Class<?> paramType = methodParam.getParameterType();
		Object argValue = resolveCommonArgument(methodParam, webRequest, thrownException);
		if (argValue != WebArgumentResolver.UNRESOLVED) {
			args[i] = argValue;
		}
		else {
			throw new IllegalStateException("Unsupported argument [" + paramType.getName() +
					"] for @ExceptionHandler method: " + handlerMethod);
		}
	}
	return args;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AnnotationMethodHandlerExceptionResolver.java

示例4: resolveHandlerArguments

/**
 * Resolves the arguments for the given method. Delegates to {@link #resolveCommonArgument}.
 */
private Object[] resolveHandlerArguments(Method handlerMethod, Object handler,
		NativeWebRequest webRequest, Exception thrownException) throws Exception {

	Class<?>[] paramTypes = handlerMethod.getParameterTypes();
	Object[] args = new Object[paramTypes.length];
	Class<?> handlerType = handler.getClass();
	for (int i = 0; i < args.length; i++) {
		MethodParameter methodParam = new MethodParameter(handlerMethod, i);
		GenericTypeResolver.resolveParameterType(methodParam, handlerType);
		Class<?> paramType = methodParam.getParameterType();
		Object argValue = resolveCommonArgument(methodParam, webRequest, thrownException);
		if (argValue != WebArgumentResolver.UNRESOLVED) {
			args[i] = argValue;
		}
		else {
			throw new IllegalStateException("Unsupported argument [" + paramType.getName() +
					"] for @ExceptionHandler method: " + handlerMethod);
		}
	}
	return args;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:AnnotationMethodHandlerExceptionResolver.java

示例5: supportsParameter

/**
 * Actually resolve the value and check the resolved value is not
 * {@link WebArgumentResolver#UNRESOLVED} absorbing _any_ exceptions.
 */
public boolean supportsParameter(MethodParameter parameter) {
	try {
		NativeWebRequest webRequest = getWebRequest();
		Object result = this.adaptee.resolveArgument(parameter, webRequest);
		if (result == WebArgumentResolver.UNRESOLVED) {
			return false;
		}
		else {
			return ClassUtils.isAssignableValue(parameter.getParameterType(), result);
		}
	}
	catch (Exception ex) {
		// ignore (see class-level doc)
		logger.debug("Error in checking support for parameter [" + parameter + "], message: " + ex.getMessage());
		return false;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:AbstractWebArgumentResolverAdapter.java

示例6: resolveArgument

/**
 * Delegate to the {@link WebArgumentResolver} instance.
 * @exception IllegalStateException if the resolved value is not assignable
 * to the method parameter.
 */
public Object resolveArgument(
		MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
		throws Exception {

	Class<?> paramType = parameter.getParameterType();
	Object result = this.adaptee.resolveArgument(parameter, webRequest);
	if (result == WebArgumentResolver.UNRESOLVED || !ClassUtils.isAssignableValue(paramType, result)) {
		throw new IllegalStateException(
				"Standard argument type [" + paramType.getName() + "] in method " + parameter.getMethod() +
				"resolved to incompatible value of type [" + (result != null ? result.getClass() : null) +
				"]. Consider declaring the argument type in a less specific fashion.");
	}
	return result;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:AbstractWebArgumentResolverAdapter.java

示例7: resolveArgument

/**
 * Delegate to the {@link WebArgumentResolver} instance.
 * @exception IllegalStateException if the resolved value is not assignable
 * to the method parameter.
 */
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	Class<?> paramType = parameter.getParameterType();
	Object result = this.adaptee.resolveArgument(parameter, webRequest);
	if (result == WebArgumentResolver.UNRESOLVED || !ClassUtils.isAssignableValue(paramType, result)) {
		throw new IllegalStateException(
				"Standard argument type [" + paramType.getName() + "] in method " + parameter.getMethod() +
				"resolved to incompatible value of type [" + (result != null ? result.getClass() : null) +
				"]. Consider declaring the argument type in a less specific fashion.");
	}
	return result;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AbstractWebArgumentResolverAdapter.java

示例8: resolveArgument

@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer mavContainer,
		NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

	if (supportsParameter(methodParameter)) {
		return createUserDetails(webRequest);
	}
	else {
		return WebArgumentResolver.UNRESOLVED;
	}
}
 
开发者ID:cternes,项目名称:slackspace-angular-spring-keycloak,代码行数:11,代码来源:UserDetailsArgumentResolver.java

示例9: resolveArgument

public Object resolveArgument(MethodParameter methodParameter,
                              ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
                              WebDataBinderFactory binderFactory) throws Exception {
    if (this.supportsParameter(methodParameter)) {
        return securityUtils.getCurrentUser();
    } else {
        return WebArgumentResolver.UNRESOLVED;
    }
}
 
开发者ID:lhartikk,项目名称:spring-tsers-auth,代码行数:9,代码来源:CurrentUserHandlerMethodArgumentResolver.java

示例10: resolveArgument

/**
* spring 3.1之前
*/
  @Override
  public Object resolveArgument(MethodParameter parameter, NativeWebRequest request) throws Exception {
      if(!supportsParameter(parameter)) {
          return WebArgumentResolver.UNRESOLVED;
      }
      return resolveArgument(parameter, null, request, null);
  }
 
开发者ID:thinking-github,项目名称:nbone,代码行数:10,代码来源:JsonRequestParamMethodArgumentResolver.java

示例11: resolveArgument

@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer mavc,
        NativeWebRequest webRequest, WebDataBinderFactory wdbf) throws Exception {
    if (this.supportsParameter(methodParameter)) {
        Principal principal = webRequest.getUserPrincipal();
        return (User) ((Authentication) principal).getPrincipal();
    } else {
        return WebArgumentResolver.UNRESOLVED;
    }
}
 
开发者ID:gjong,项目名称:web-harvester,代码行数:10,代码来源:CurrentUserResolver.java

示例12: resolveArgument

@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer mavContainer,
                              NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    if (this.supportsParameter(methodParameter)) {
        return getCurrentUser();
    }
    else {
        return WebArgumentResolver.UNRESOLVED;
    }
}
 
开发者ID:chrludwig,项目名称:websec-saml2sp,代码行数:10,代码来源:CurrentUserHandlerMethodArgumentResolver.java

示例13: resolveArgument

public Object resolveArgument(MethodParameter methodParameter,
		ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
		WebDataBinderFactory binderFactory) throws Exception {
	if (this.supportsParameter(methodParameter)) {
		Principal principal = (Principal) webRequest.getUserPrincipal();
		return (User) ((Authentication) principal).getPrincipal();
	} else {
		return WebArgumentResolver.UNRESOLVED;
	}
}
 
开发者ID:vdenotaris,项目名称:spring-boot-security-saml-sample,代码行数:10,代码来源:CurrentUserHandlerMethodArgumentResolver.java

示例14: resolveArgument

public Object resolveArgument(MethodParameter methodParam, NativeWebRequest nativeWebRequest) throws Exception {
   DatatablesParams parameterAnnotation = methodParam.getParameterAnnotation(DatatablesParams.class);

   if (parameterAnnotation != null) {
      HttpServletRequest request = (HttpServletRequest) nativeWebRequest.getNativeRequest();
      return DatatablesCriterias.getFromRequest(request);
   }

   return WebArgumentResolver.UNRESOLVED;
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:10,代码来源:DatatablesCriteriasResolver.java

示例15: resolveInitBinderArguments

private Object[] resolveInitBinderArguments(Object handler, Method initBinderMethod,
		WebDataBinder binder, NativeWebRequest webRequest) throws Exception {

	Class<?>[] initBinderParams = initBinderMethod.getParameterTypes();
	Object[] initBinderArgs = new Object[initBinderParams.length];

	for (int i = 0; i < initBinderArgs.length; i++) {
		MethodParameter methodParam = new MethodParameter(initBinderMethod, i);
		methodParam.initParameterNameDiscovery(this.parameterNameDiscoverer);
		GenericTypeResolver.resolveParameterType(methodParam, handler.getClass());
		String paramName = null;
		boolean paramRequired = false;
		String paramDefaultValue = null;
		String pathVarName = null;
		Annotation[] paramAnns = methodParam.getParameterAnnotations();

		for (Annotation paramAnn : paramAnns) {
			if (RequestParam.class.isInstance(paramAnn)) {
				RequestParam requestParam = (RequestParam) paramAnn;
				paramName = requestParam.value();
				paramRequired = requestParam.required();
				paramDefaultValue = parseDefaultValueAttribute(requestParam.defaultValue());
				break;
			}
			else if (ModelAttribute.class.isInstance(paramAnn)) {
				throw new IllegalStateException(
						"@ModelAttribute is not supported on @InitBinder methods: " + initBinderMethod);
			}
			else if (PathVariable.class.isInstance(paramAnn)) {
				PathVariable pathVar = (PathVariable) paramAnn;
				pathVarName = pathVar.value();
			}
		}

		if (paramName == null && pathVarName == null) {
			Object argValue = resolveCommonArgument(methodParam, webRequest);
			if (argValue != WebArgumentResolver.UNRESOLVED) {
				initBinderArgs[i] = argValue;
			}
			else {
				Class<?> paramType = initBinderParams[i];
				if (paramType.isInstance(binder)) {
					initBinderArgs[i] = binder;
				}
				else if (BeanUtils.isSimpleProperty(paramType)) {
					paramName = "";
				}
				else {
					throw new IllegalStateException("Unsupported argument [" + paramType.getName() +
							"] for @InitBinder method: " + initBinderMethod);
				}
			}
		}

		if (paramName != null) {
			initBinderArgs[i] =
					resolveRequestParam(paramName, paramRequired, paramDefaultValue, methodParam, webRequest, null);
		}
		else if (pathVarName != null) {
			initBinderArgs[i] = resolvePathVariable(pathVarName, methodParam, webRequest, null);
		}
	}

	return initBinderArgs;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:65,代码来源:HandlerMethodInvoker.java


注:本文中的org.springframework.web.bind.support.WebArgumentResolver.UNRESOLVED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。