I have web application on spring.I have so form:
<form:form action="submitFormAdd" id="formId" method="GET" modelAttribute="myCandidate">
<label for="nameInput" path="name"> Name</label>
<form:input path="name" id="nameInput"></form:input>
<form:errors path="name" cssclass="error"></form:errors>
</form:form>
and so handler:
@RequestMapping("/submitFormAdd")
public String submitFormAdd(Model model
,@ModelAttribute @Valid Candidate myCandidate
,BindingResult result
,@ModelAttribute("skillsIdList") Set<Skill> skills
,@ModelAttribute("vacanciesForCandidate") Set<Vacancy> vacanciesForCandidate){
if(result.hasErrors()) {
return "candidateDetailsAdd";
}
return "candidateMenu";
}
if I type less 10 symbols result.hasErrors() equals true, but I don't see errors on jsp page( class from model:
public class Candidate {
@Size(min=10)
private String name;
//getters and setters
}
how to fix it?
P.S. properties(/ui/src/main/resources/messages.properties):
Size.myCandidate.name = more size please
NotNull = Field cannot be left blank
NotEmpty = not empty
and config:
public class UiConfig {
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
}
}