读书人

Struts标签lt;html:cancel/gt;撤除按钮处理

发布时间: 2012-08-21 13:00:21 作者: rapoo

Struts标签<html:cancel/>取消按钮处理事件

<html:cancel/>标签默认情况下点击,是会报错的。

?

要想使用此按钮可以在 struts-config.xml 中的action 增加如下相应属性:

?

<set-property property="cancellable" value="true" />

?

详细位置如下所示:

?

<action      attribute="helloForm"      input="/form/hello.jsp"      name="helloForm"      path="/hello"      scope="request"      type="com.zwn.struts.action.HelloAction">     <set-property property="cancellable" value="true"/>          <forward name="success" path="/form/helloSuccess.jsp" />     <forward name="fail" path="/form/helloFail.jsp"  redirect="true"/>?</action>
??

?

再在对应action里面增加对cancel按钮的处理方法:

?

?
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {              if (isCancelled(request)) { // 取消按钮处理return mapping.findForward("fail");}HelloForm helloForm = (HelloForm) form;return mapping.findForward("success");}
??

?

?

?

读书人网 >CSS

热点推荐