私はSpring MVCフレームワークを使用して、jspからdispatcher-servlet.xmlのマッピングで定義されたコントローラーにデータをポスト送信しています。
しかし、コントローラーはロード中にのみ呼び出されます。つまり、ページのロード中に..
jspページで送信をクリックすると、コントローラーのonsubmitがヒットすることはありません...
問題の周りで私を助けてください..
index.jsp
<form form method="post" commandName="postsubmit">
<table>
<tr>
<td> <b>cal pool: </b></td> <td> <input type="text"> </input> </td>
</tr>
<tr>
<td> <b>date: </b></td> <td> <input type="text"> </input> </td>
</tr>
</br>
</br>
<tr>
<td> <input type="submit" value="submit"/> </td>
</tr>
</table>
</form>
dispatcher-servlet.xml
<bean name="/index.htm" class="PostSubmitController">
<property name="sessionForm" value="true"/>
<property name="commandName" value="postsubmit"/>
<property name="commandClass" value="PostSubmit"/>
<property name="formView" value="index"/>
<property name="successView" value="success.htm"/>
<property name="postSubmit" ref="postSubmit"/>
</bean>
PostSubmitController
public class PostSubmitController extends SimpleFormController{
private PostSubmit _postsubmit;
protected final Log logger = LogFactory.getLog(getClass());
public ModelAndView onSubmit(Object command)
throws ServletException {
System.out.println("hello");
logger.info("debug1");
String _getcal_pool = ((PostSubmit) command).getCal_pool();
logger.info("debug2");
Date _getcal_date = ((PostSubmit) command).getDate();
logger.info("debug3");
logger.info("get_cal_pool:" + _getcal_pool );
logger.info("get_cal_date:" + _getcal_date.toString() );
logger.info("debug4");
logger.info("returning from PostSubmitController view to " + getSuccessView());
return new ModelAndView(new RedirectView(getSuccessView()));
}
public void setPostSubmit(PostSubmit postSubmit) {
System.out.println("hello");
logger.info("debug5");
this._postsubmit = postSubmit;
}
public PostSubmit getPostSubmit() {
System.out.println("hello");
logger.info("debug6");
return _postsubmit;
}
public ModelAndView processFormSubmission(HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception
{
System.out.println("hello in processFormSubmission");
logger.info("returning from processFormSubmission view to " + getSuccessView());
return new ModelAndView(new RedirectView(getSuccessView()));
}
}