當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。