Custom Validation & Read Property File Data-Spring
Custom Validation & Read Property File Data-Spring
</bean>
Messages. Properties:
1. customer.age.empty = Age is required
Custom Validation:
@Component
//Business validation
errors.rejectValue("age", "customer.age.range.invalid");
}}
@Autowired
CustomerValidator customerValidator;
public String doLogin(@Valid Customer customer, BindingResult result,Model model) {
model.addAttribute("customer",customer);
if(result.hasErrors()){
return "register";
return "home";
@InitBinder
webDataBinder.setValidator(customerValidator);
And remove the below code which we make an explicit call to validate
customerValidator.validate(customer, result);