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


Java WebDataBinder.validate方法代码示例

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


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

示例1: validate

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
private void validate(WebDataBinder binder, MethodParameter parameter) throws Exception, MethodArgumentNotValidException {

		Annotation[] annotations = parameter.getParameterAnnotations();
		for (Annotation annot : annotations) {
			if (annot.annotationType().getSimpleName().startsWith("Valid")) {
				Object hints = AnnotationUtils.getValue(annot);
				binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
				BindingResult bindingResult = binder.getBindingResult();
				if (bindingResult.hasErrors()) {
					if (isBindExceptionRequired(binder, parameter)) {
						throw new MethodArgumentNotValidException(parameter, bindingResult);
					}
				}
				break;
			}
		}
	}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:18,代码来源:JsonRequestBodyMethodProcessor.java

示例2: validateComponent

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
protected void validateComponent(WebDataBinder binder, MethodParameter parameter) throws BindException {

        boolean validateParameter = validateParameter(parameter);
        Annotation[] annotations = binder.getTarget().getClass().getAnnotations();
        for (Annotation annot : annotations) {
            if (annot.annotationType().getSimpleName().startsWith("Valid") && validateParameter) {
                Object hints = AnnotationUtils.getValue(annot);
                binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[]{hints});
            }
        }

        if (binder.getBindingResult().hasErrors()) {
            if (isBindExceptionRequired(binder, parameter)) {
                throw new BindException(binder.getBindingResult());
            }
        }
    }
 
开发者ID:thinking-github,项目名称:nbone,代码行数:18,代码来源:FormModelMethodArgumentResolver.java

示例3: validateComponent

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
protected void validateComponent(WebDataBinder binder, MethodParameter parameter) throws BindException {
    
    boolean validateParameter = validateParameter(parameter);
    Annotation[] annotations = binder.getTarget().getClass().getAnnotations();
    for (Annotation annot : annotations) {
        if (annot.annotationType().getSimpleName().startsWith("Valid") && validateParameter) {
            Object hints = AnnotationUtils.getValue(annot);
            binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
        }
    }

    if (binder.getBindingResult().hasErrors()) {
        if (isBindExceptionRequired(binder, parameter)) {
            throw new BindException(binder.getBindingResult());
        }
    }
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:18,代码来源:FormModelMethodArgumentResolver.java

示例4: validateIfApplicable

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
/**
 * Validate the model attribute if applicable.
 * <p>The default implementation checks for {@code @javax.validation.Valid}.
 * @param binder the DataBinder to be used
 * @param parameter the method parameter
 */
protected void validateIfApplicable(WebDataBinder binder, MethodParameter parameter) {
	Annotation[] annotations = parameter.getParameterAnnotations();
	for (Annotation annot : annotations) {
		if (annot.annotationType().getSimpleName().startsWith("Valid")) {
			Object hints = AnnotationUtils.getValue(annot);
			binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
			break;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ModelAttributeMethodProcessor.java

示例5: doBind

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
private void doBind(WebDataBinder binder, NativeWebRequest webRequest, boolean validate,
		Object[] validationHints, boolean failOnErrors) throws Exception {

	doBind(binder, webRequest);
	if (validate) {
		binder.validate(validationHints);
	}
	if (failOnErrors && binder.getBindingResult().hasErrors()) {
		throw new BindException(binder.getBindingResult());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:HandlerMethodInvoker.java

示例6: validateIfApplicable

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
/**
 * Validate the request part if applicable.
 * <p>The default implementation checks for {@code @javax.validation.Valid},
 * Spring's {@link org.springframework.validation.annotation.Validated},
 * and custom annotations whose name starts with "Valid".
 * @param binder the DataBinder to be used
 * @param methodParam the method parameter
 * @see #isBindExceptionRequired
 * @since 4.1.5
 */
protected void validateIfApplicable(WebDataBinder binder, MethodParameter methodParam) {
	Annotation[] annotations = methodParam.getParameterAnnotations();
	for (Annotation ann : annotations) {
		Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class);
		if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) {
			Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann));
			Object[] validationHints = (hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
			binder.validate(validationHints);
			break;
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:AbstractMessageConverterMethodArgumentResolver.java

示例7: validateIfApplicable

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
/**
 * Validate the model attribute if applicable.
 * <p>The default implementation checks for {@code @javax.validation.Valid},
 * Spring's {@link org.springframework.validation.annotation.Validated},
 * and custom annotations whose name starts with "Valid".
 * @param binder the DataBinder to be used
 * @param methodParam the method parameter
 */
protected void validateIfApplicable(WebDataBinder binder, MethodParameter methodParam) {
	Annotation[] annotations = methodParam.getParameterAnnotations();
	for (Annotation ann : annotations) {
		Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class);
		if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) {
			Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann));
			Object[] validationHints = (hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
			binder.validate(validationHints);
			break;
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:ModelAttributeMethodProcessor.java

示例8: validateIfApplicable

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
protected void validateIfApplicable(WebDataBinder binder, MethodParameter parameter) {
	Annotation[] annotations = parameter.getParameterAnnotations();
	for (Annotation annot : annotations) {
		if (annot.annotationType().getSimpleName().startsWith("Valid")) {
			Object hints = AnnotationUtils.getValue(annot);
			binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
			break;
		}
	}
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:11,代码来源:BaseMethodArgumentResolver.java

示例9: validateIfApplicable

import org.springframework.web.bind.WebDataBinder; //导入方法依赖的package包/类
/**
 * Validate the model attribute if applicable.
 * <p>The default implementation checks for {@code @javax.validation.Valid}.
 * @param binder the DataBinder to be used
 * @param parameter the method parameter
 */
protected void validateIfApplicable(WebDataBinder binder, MethodParameter parameter) {
    Annotation[] annotations = parameter.getParameterAnnotations();
    for (Annotation annot : annotations) {
        if (annot.annotationType().getSimpleName().startsWith("Valid")) {
            Object hints = AnnotationUtils.getValue(annot);
            binder.validate(hints instanceof Object[] ? (Object[]) hints : new Object[] {hints});
        }
    }
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:16,代码来源:FormModelMethodArgumentResolver.java


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