{"id":1670,"date":"2017-07-20T16:34:08","date_gmt":"2017-07-20T08:34:08","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1670"},"modified":"2017-07-20T16:34:08","modified_gmt":"2017-07-20T08:34:08","slug":"cancellableformcontroller%ef%bc%88%e5%8f%96%e6%b6%88%e8%a1%a8%e5%8d%95%e6%8e%a7%e5%88%b6%e5%99%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1670","title":{"rendered":"CancellableFormController\uff08\u53d6\u6d88\u8868\u5355\u63a7\u5236\u5668\uff09"},"content":{"rendered":"<p>\n\tCancellableFormController\uff08\u53d6\u6d88\u8868\u5355\u63a7\u5236\u5668\uff09\u7ee7\u627fSimpleFormController\uff0c\u989d\u5916\u63d0\u4f9b\u53d6\u6d88\u8868\u5355\u529f\u80fd\u3002\n<\/p>\n<ul>\n<li>\n\t\t\u8868\u5355\u5c55\u793a\uff1a\u548cSimpleFormController\u4e00\u6837\uff1b\n\t<\/li>\n<li>\n\t\t\u8868\u5355\u53d6\u6d88\uff1a\u548cSimpleFormController\u4e00\u6837\uff1b\n\t<\/li>\n<li>\n\t\t\u8868\u5355\u6210\u529f\u63d0\u4ea4\uff1a\u53d6\u6d88\u529f\u80fd\u5904\u7406\u65b9\u6cd5\u4e3a\uff1aonCancel(Object command)\uff0c\u800c\u4e14\u9ed8\u8ba4\u8fd4\u56decancelView\u5c5e\u6027\u6307\u5b9a\u7684\u903b\u8f91\u89c6\u56fe\u540d\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u90a3\u5982\u4f55\u5224\u65ad\u662f\u53d6\u6d88\u5462\uff1f\u5982\u679c\u8bf7\u6c42\u4e2d\u6709\u53c2\u6570\u540d\u4e3a&ldquo;_cancel&rdquo;\u7684\u53c2\u6570\uff0c\u5219\u8868\u793a\u8868\u5355\u53d6\u6d88\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7cancelParamKey\u6765\u4fee\u6539\u53c2\u6570\u540d\uff08\u5982&ldquo;_cancel.x&rdquo;\u7b49\uff09\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"CancellableFormController \u5904\u7406\u6d41\u7a0b\" src=\"http:\/\/ocuzluml6.bkt.clouddn.com\/CancellableFormController.JPG\" style=\"width: 543px;height: 224px\" \/>\n<\/p>\n<p>\n\t\u4e0b\u9762\u5f00\u59cb\u63a7\u5236\u5668\u90e8\u5206\u4ee3\u7801\u3002\n<\/p>\n<p>\n\t\u590d\u5236RegisterSimpleFormController\u4e00\u4efd\u547d\u540d\u4e3aCanCancelRegisterSimpleFormController\uff0c\u6dfb\u52a0\u53d6\u6d88\u529f\u80fd\u5904\u7406\u65b9\u6cd5\u5b9e\u73b0\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@Override  \r\nprotected ModelAndView onCancel(Object command) throws Exception {  \r\n    UserModel user = (UserModel) command;  \r\n    \/\/TODO \u8c03\u7528\u4e1a\u52a1\u5bf9\u8c61\u5904\u7406  \r\n    System.out.println(user);  \r\n    return super.onCancel(command);  \r\n} <\/pre>\n<ul>\n<li>\n\t\tonCancel\uff1a\u5728\u8be5\u529f\u80fd\u65b9\u6cd5\u5185\u5b9e\u73b0\u53d6\u6d88\u903b\u8f91\uff0c\u7236\u7c7b\u7684onCancel\u65b9\u6cd5\u9ed8\u8ba4\u8fd4\u56decancelView\u5c5e\u6027\u6307\u5b9a\u7684\u903b\u8f91\u89c6\u56fe\u540d\u3002\n\t<\/li>\n<\/ul>\n<p>\n\tspring\u914d\u7f6e\u6587\u4ef6\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;bean name=&quot;\/canCancelForm&quot;   \r\nclass=&quot;com.xttblog.chapter4.web.controller.CanCancelRegisterSimpleFormController&quot;&gt;  \r\n        &lt;property name=&quot;formView&quot; value=&quot;register&quot;\/&gt;  \r\n        &lt;property name=&quot;successView&quot; value=&quot;redirect:\/success&quot;\/&gt;  \r\n        &lt;property name=&quot;cancelView&quot; value=&quot;redirect:\/cancel&quot;\/&gt;  \r\n&lt;\/bean&gt;  \r\n&lt;bean name=&quot;\/cancel&quot; class=&quot;com.xttblog.chapter4.web.controller.CancelController&quot;\/&gt;<\/pre>\n<ul>\n<li>\n\t\tcancelParamKey\uff1a\u7528\u4e8e\u5224\u65ad\u662f\u5426\u662f\u53d6\u6d88\u7684\u8bf7\u6c42\u53c2\u6570\u540d\uff0c\u9ed8\u8ba4\u662f_cancel\uff0c\u5373\u5982\u679c\u8bf7\u6c42\u53c2\u6570\u6570\u636e\u4e2d\u542b\u6709\u540d\u5b57_cancel\u5219\u8868\u793a\u662f\u53d6\u6d88\uff0c\u5c06\u8c03\u7528onCancel\u529f\u80fd\u5904\u7406\u65b9\u6cd5\uff1b\n\t<\/li>\n<li>\n\t\tcancelView\uff1a\u8868\u793a\u53d6\u6d88\u65f6\u65f6\u663e\u793a\u7684\u9875\u9762\uff1b&ldquo;redirect:\/cancel&rdquo;\u8868\u793a\u6210\u529f\u5904\u7406\u540e\u91cd\u5b9a\u5411\u5230\/cancel\u63a7\u5236\u5668\uff1b\u9632\u6b62\u8868\u5355\u91cd\u590d\u63d0\u4ea4\uff1b&ldquo;\/cancel&rdquo; bean\u7684\u4f5c\u7528\u662f\u663e\u793a\u53d6\u6d88\u9875\u9762\uff0c\u6b64\u5904\u5c31\u4e0d\u5217\u4e3e\u4e86\uff08\u8be6\u89c1\u4ee3\u7801\uff09\u3002\n\t<\/li>\n<\/ul>\n<p>\n\t\u89c6\u56fe\u9875\u9762\uff08\u4fee\u6539register.jsp\uff09\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;input type=&quot;submit&quot; name=&quot;_cancel&quot; value=&quot;\u53d6\u6d88&quot;\/&gt; <\/pre>\n<p>\n\t\u8be5\u63d0\u4ea4\u6309\u94ae\u7684\u4f5c\u7528\u662f\u53d6\u6d88\uff0c\u56e0\u4e3aname=&quot;_cancel&quot;\uff0c\u5373\u8bf7\u6c42\u540e\u4f1a\u6709\u4e00\u4e2a\u540d\u5b57\u4e3a_cancel\u7684\u53c2\u6570\uff0c\u56e0\u6b64\u4f1a\u6267\u884conCancel\u529f\u80fd\u5904\u7406\u65b9\u6cd5\u3002\n<\/p>\n<p>\n\t\u6d4b\u8bd5\u6b65\u9aa4\uff1a\u5728\u6d4f\u89c8\u5668\u8f93\u5165&ldquo;http:\/\/localhost:9080\/springmvc-chapter4\/canCancelForm&rdquo;\uff0c\u5219\u9996\u5148\u5230\u5c55\u793a\u89c6\u56fe\u9875\u9762\uff0c\u70b9\u51fb&ldquo;\u53d6\u6d88\u6309\u94ae&rdquo;\u5c06\u91cd\u5b9a\u5411\u5230&ldquo;http:\/\/localhost:9080\/springmvc-chapter4\/cancel&rdquo;\uff0c\u8bf4\u660e\u53d6\u6d88\u6210\u529f\u4e86\u3002\n<\/p>\n<p>\n\t\u5b9e\u9645\u9879\u76ee\u53ef\u80fd\u4f1a\u51fa\u73b0\u6bd4\u5982\u4e00\u4e9b\u7f51\u7ad9\u7684\u5b8c\u5584\u4e2a\u4eba\u8d44\u6599\u90fd\u662f\u591a\u4e2a\u9875\u9762\uff08\u5373\u591a\u6b65\uff09\uff0c\u90a3\u5e94\u8be5\u600e\u4e48\u5b9e\u73b0\u5462\uff1f\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u770b\u4e00\u4e0bspring Web MVC\u63d0\u4f9b\u7684\u5bf9\u591a\u6b65\u8868\u5355\u7684\u652f\u6301\u7c7bAbstractWizardFormController\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=1670\">CancellableFormController\uff08\u53d6\u6d88\u8868\u5355\u63a7\u5236\u5668\uff09<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>CancellableFormController\uff08\u53d6\u6d88\u8868\u5355\u63a7\u5236\u5668\uff09\u7ee7\u627fSimpleFormControlle [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1386,1350,1359],"class_list":["post-1670","post","type-post","status-publish","format-standard","hentry","category-java","tag-cancellableformcontroller","tag-spring-mvc","tag-spring-mvc-"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1670"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1670\/revisions"}],"predecessor-version":[{"id":1671,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1670\/revisions\/1671"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}