Tag: spring validator

这个嵌套注释做什么/允许什么?

我正在查看@org.hibernate.validator.constaints.NotEmpty注释: @Documented @Constraint(validatedBy = { }) @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @ReportAsSingleViolation @NotNull @Size(min = 1) public @interface NotEmpty { String message() default “{org.hibernate.validator.constraints.NotEmpty.message}”; Class[] groups() default { }; Class[] payload() default { }; /** * Defines several {@code @NotEmpty} annotations on the same element. */ @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER […]

Spring MVC:ModelAndViewContainer:View是; 默认模型{Some-Object}

我使用带有ContentNegotiatingViewResolver Spring-mvc来处理我的响应对象并解析成特定的格式。 当我从控制器返回对象时,作为响应它添加我的响应对象,但也添加我用于映射请求参数的对象。 我的控制器充当rest控制器。 因为我想使用带有ContentNegotiatingViewResolver spring创建rest-services。 调试之后,我找到了InvocableHandlerMethdod类,其中invokeForRequest方法包含以下参数: public final Object invokeForRequest(NativeWebRequest request, ModelAndViewContainer mavContainer, Object… providedArgs) throws Exception { ……………………………………….. 在ModelAndViewContainer参数中包含以下详细信息: ModelAndViewContainer: View is [null]; default model {oauthClientDetail=com.netsol.entities.OauthClientDetail@9ac35e, org.springframework.validation.BindingResult.oauthClientDetail=org.springframework.validation.BeanPropertyBindingResult: 0 errors} 我无法OauthClientDetail ,为什么在ModelAndViewContainer设置OauthClientDetail对象以及我如何防止这种情况。 Follwing是我的控制器代码: @RequestMapping(value = “/changePassword”, method = RequestMethod.POST) public ApiResponse changePassword(@Valid OauthClientDetail clientDetail, BindingResult bindingResult, @RequestParam(value = “password”, required = true) String password) […]

Spring-Data-Restvalidation器

我一直在尝试将弹簧validation器添加到spring-data-rest项目中。 我跟着并通过以下链接设置“入门”应用程序: http : //spring.io/guides/gs/accessing-data-rest/ …现在我正在尝试通过以下文档添加自定义PeopleValidator: http ://docs.spring.io/spring-data/rest/docs/2.1.0.RELEASE/reference/html/validation-chapter html的 我的自定义PeopleValidator看起来像 package hello; import org.springframework.validation.Errors; import org.springframework.validation.Validator; public class PeopleValidator implements Validator { @Override public boolean supports(Class clazz) { return true; } @Override public void validate(Object target, Errors errors) { errors.reject(“DIE”); } } …而我的Application.java类现在看起来像这样 package hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; […]