As you could see in the article about
validation in Spring, the object handling validation result must be defined directly after validated object (for example object annotated with @Valid). So, this signature is correct:
public String registerHandle(@ModelAttribute("subscriber") @Valid Subscriber subscriber, BindingResult binRes, Model layout, HttpServletRequest req, RedirectAttributes redAtt)
While this one will cause following exception:
public String registerHandle(@ModelAttribute("subscriber") @Valid Subscriber subscriber, Model layout, HttpServletRequest req, BindingResult binRes, RedirectAttributes redAtt)
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult:
1 errors
Field error in object 'subscriber' on field 'login': rejected value [];
codes [Size.subscriber.login,Size.login,Size.java.lang.String,Size]; arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes
[subscriber.login,login]; arguments []; default message [login],20,1];
default message [The length can't exced 20 chars]
org.springframework.web.util.NestedServletException: Request processing
failed; nested exception is org.springframework.validation.BindException:
org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'subscriber' on field 'login': rejected value [];
codes [Size.subscriber.login,Size.login,Size.java.lang.String,Size]; arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes
[subscriber.login,login]; arguments []; default message [login],20,1];
default message [The length can't exced 20 chars]