當我加載這個表格時,國家表格是從240個國家的數據庫填充的。如果我提交它,並帶有一些空的必填字段,頁面會重新加載錯誤消息。但我沒有得到任何國家上市。我使用相同的代碼來填充在GET和POST方法的清單 - 見下文彈簧表格不填寫表格提交
<form:form commandName="student_personal_info" method="post">
<table>
<tr>
<td><form:label path="country">Country:</form:label></td>
<td><form:select path="country">
<form:option value="NONE" label=" --Select-- "></form:option>
<form:options items="${countries}"/>
</form:select>
</td>
</tr></table>
</form:form>
@RequestMapping(value = "student_personal_info", method = RequestMethod.GET)
public ModelAndView DisplayPersonalForm(ModelAndView model) {
StudentPersonalInfo personalInfo = new StudentPersonalInfo();
model.addObject("student_personal_info", personalInfo);
model.addObject("countries",getCountries());
return model;
} //this works fine
@RequestMapping(value = "student_personal_info", method = RequestMethod.POST)
public String PersonalFormSubmitted(
@ModelAttribute("student_personal_info") @Valid StudentPersonalInfo student_personal_info,
BindingResult result, ModelAndView model) {
model.addObject("countries", getCountries());
if (result.hasErrors()) {
logger.info("From student personal info, there are "
+ String.valueOf(this.getCountries().size())
+ " Countries"); //This prints 240 countries on the consule
return "student_personal_info";
}
else
return "redirect:/display_program_of_study.tsegay";
}
其他所有我的配置能正常工作
謝謝,這解決了這個問題。 – tkt986 2011-01-09 14:04:07