2013-04-15 2 views
1

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>&nbsp;</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"; 
} 

답변

1

변경 버튼을 제출 :이 태그는 양식을 제출하지 않습니다 <input type="button" value="Submit bulletin" name="submit" />을 사용하는

input type = "submit" 
0

- 그것은 기본적으로 아무것도하지 않습니다. 주요 용도는 AJAX 애플리케이션 또는 비 아약스 처리 (UI/UX)의 일부로 JavaScript와 함께 사용됩니다.

<input type="submit" value="Submit bulletin" name="submit" /> 태그는 JavaScript로 달리 지정하지 않는 한 사용자가 클릭 할 때 양식을 제출합니다.

관련 문제