Spring 3.2 MVC 애플리케이션에 다음과 같은 형식을 가지고있다. 컨트롤러 메소드가 호출되지 않습니다. 여기 내 양식이 있습니다.Spring MVC - 아무 일도 일어나지 않는다.
<form:form commandName="bulletin" method="post" value="/processBulletin">
<table>
<tr>
<td>Name:</td>
<td><form:input path="name" maxlength="30" /></td>
</tr>
<tr>
<td>Subject:</td>
<td><form:input path="subject" maxlength="50" /></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><form:textarea path="note" cols="70" rows="20" /></td>
</tr>
<tr>
<td><input type="button" value="Submit bulletin" name="submit" /></td>
<td> </td>
</tr>
</table>
</form:form>
여기 내 컨트롤러 방법입니다.
@RequestMapping(value = "/processBulletin", method = RequestMethod.POST)
@ModelAttribute("bulletin") Bulletin bulletin, Model model,
BindingResult result) {
final BindException errors = new BindException(bulletin, "bulletin");
bulletinValidator.validate(bulletin, errors);
if (errors.hasErrors()) {
return "redirect:/approvedBulletins";
} else {
try {
bulletin.setSubject(bulletin.getSubject().trim());
bulletin.setName(bulletin.getName().trim());
bulletin.setNote(bulletin.getNote().trim());
long now = System.currentTimeMillis();
Calendar date = Calendar.getInstance();
date.setTimeInMillis(now);
bulletin.setDay((date.get(Calendar.MONTH) + 1) + "/"
+ date.get(Calendar.DATE) + "/"
+ date.get(Calendar.YEAR));
bulletinDAO.writeBulletin(bulletin.getName(),
bulletin.getSubject(), bulletin.getDay(),
bulletin.getNote());
} catch (Exception e) {
System.out.println(e.getMessage());
return "FailurePage";
}
}
return "redirect:/approvedBulletins";
}