|
|
|
|
@ -1575,6 +1575,7 @@ public class ServletAnnotationControllerTests {
@@ -1575,6 +1575,7 @@ public class ServletAnnotationControllerTests {
|
|
|
|
|
@InitBinder |
|
|
|
|
private void initBinder(WebDataBinder binder) { |
|
|
|
|
binder.initBeanPropertyAccess(); |
|
|
|
|
binder.setRequiredFields("sex"); |
|
|
|
|
LocalValidatorFactoryBean vf = new LocalValidatorFactoryBean(); |
|
|
|
|
vf.afterPropertiesSet(); |
|
|
|
|
binder.setValidator(vf); |
|
|
|
|
@ -1582,6 +1583,15 @@ public class ServletAnnotationControllerTests {
@@ -1582,6 +1583,15 @@ public class ServletAnnotationControllerTests {
|
|
|
|
|
dateFormat.setLenient(false); |
|
|
|
|
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@RequestMapping("/myPath.do") |
|
|
|
|
public String myHandle(@ModelAttribute("myCommand") @Valid TestBean tb, BindingResult errors, ModelMap model) { |
|
|
|
|
if (!errors.hasFieldErrors("sex")) { |
|
|
|
|
throw new IllegalStateException("requiredFields not applied"); |
|
|
|
|
} |
|
|
|
|
return super.myHandle(tb, errors, model); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
|