The submited csvUploadForm which contains a file input field has been populated successfully and the csvValidator works fine.
I want it to be displayed once more in the JSP file so as to acknowledge the validation failed file input field.
The strange thing is that form:errors path="feedItem" works just fine while form:input path="feedItem" is always empty.
What is the problem?
@RequestMapping(value = "upload", method = RequestMethod.POST)
public ModelAndView csvUploadCheck(@ModelAttribute("csvUploadBean") CSVUploadBean csvUploadForm,
BindingResult bindingResult)
throws Exception {
csvValidator.validate(csvUploadForm, bindingResult);
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = this.initFormModelAndView();
List<String> errors = buildErrorMessages(bindingResult);
modelAndView.addObject(CSV_MODEL_ATTRIBUTE, csvUploadForm);
modelAndView.addObject("errors", errors);
return modelAndView;
} else {
final ContentModelAndView redirectModelView = new ContentModelAndView();
redirectModelView.setViewName("redirect:foo");
return redirectModelView;
}
}
<form:form method="POST" modelAttribute="csvUploadBean" enctype="multipart/form-data">
<a:section id="mylayout-middle">
<c:forEach items="${errors}" var="error">
<a:alert alertType="${'error'}" spacing="${'base'}">
"${error}"
</a:alert>
</c:forEach>
<form:input path="feedItem" name="feedItem" type="file" />
<form:errors path="feedItem" cssStyle="color: #ff0000;"
</form:form>
Aucun commentaire:
Enregistrer un commentaire