{"id":103,"date":"2013-04-27T15:48:49","date_gmt":"2013-04-27T07:48:49","guid":{"rendered":"http:\/\/www.dongcb.com\/?p=103"},"modified":"2013-04-27T15:48:49","modified_gmt":"2013-04-27T07:48:49","slug":"struts1%e5%bc%80%e5%8f%91%e6%b5%81%e7%a8%8b%e6%8f%8f%e8%bf%b0","status":"publish","type":"post","link":"https:\/\/www.dongchangbin.net.cn\/?p=103","title":{"rendered":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0"},"content":{"rendered":"<p>\u6211\u4eec\u5728\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u4e00\u6b65\u4e00\u6b65\u7684\u8bb2\u89e3Struts\u7684\u5e94\u7528\uff0c\u4ee5\u8fd9\u6837\u7684\u5f62\u5f0f\u6253\u5f00Struts\u4e00\u9053\u9053\u795e\u79d8\u7684\u5927\u95e8\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u8fc7\u7a0b\uff0c\u76f8\u4fe1\u4e5f\u80fd\u6fc0\u8d77\u4f60\u5728\u5e94\u7528\u5f00\u53d1\u4e2d\u5982\u4f55\u5e94\u7528Struts\u7684\u7075\u611f\u3002\u5982\u679c\u4f60\u5bf9Struts\u7684\u4e00\u4e9b\u672f\u8bed\u4e0d\u662f\u5f88\u6e05\u695a\u7684\u8bdd\uff0c\u53ef\u4ee5\u53c2\u8003\u672c\u7cfb\u5217\u524d\u4e00\u7bc7\u5bf9Struts\u4f5c\u5927\u4f53\u4ecb\u7ecd\u7684\u6587\u7ae0\u3002<br \/>\n\u518d\u6b21\u91cd\u590d\u4e00\u904d\uff0c\u672c\u6587\u9700\u8981\u8bfb\u8005\u6709\u5982\u4e0b\u51e0\u65b9\u9762\u7684\u77e5\u8bc6\u548c\u7ecf\u9a8c\uff1aJSP\uff0cServlets\uff0c\u81ea\u5b9a\u4e49\u6807\u7b7e\u5e93\uff08CustomTaglibraries\uff09\u548cXML\u3002\u6b64\u5916\uff0c\u5728\u672c\u6587\u4e2d\uff0c\u6211\u8fd8\u4f1a\u7528\u5230Jakarta\u9879\u76ee\u7ec4\u5176\u4ed6\u4e00\u4e9b\u597d\u4e1c\u4e1c\uff0c\u6bd4\u5982Tomcat\uff08\u5b9e\u73b0Servlet\u548cJSP\u5b98\u65b9\u6807\u51c6\u7684Servlet\u5bb9\u5668\uff0c\u901a\u4fd7\u7684\u8bb2\u5c31\u662f\u4e00\u4e2aJSP\u7684Web\u5566\uff09\u548cAnt\uff08\u57fa\u4e8eJava\u7684\u81ea\u52a8\u7f16\u8bd1\u53d1\u5e03\u5de5\u5177\uff0c\u8fd9\u53ef\u662f\u597d\u4e1c\u4e1c\u554a\uff09\u3002<br \/>\n\u4f5c\u4e3a\u4e00\u540d\u4e00\u76f4\u4f7f\u7528\u524d\u6cbf\u6280\u672f\u5f00\u53d1\u4e86\u8bf8\u591a\u5e94\u7528\u7684\u6280\u672f\u4eba\u5458\uff0c\u6211\u4e00\u76f4\u575a\u4fe1\u638c\u63e1\u65b0\u6280\u672f\uff0c\u7406\u89e3\u8be5\u6280\u672f\u5f00\u53d1\u7684\u903b\u8f91\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u4f46\u8fd9\u5f80\u5f80\u5c31\u662f\u9677\u4f4f\u6211\u4eec\u5b66\u4e60\u6b65\u4f10\u7684\u6ce5\u6f6d\uff0c\u6b63\u56e0\u5982\u6b64\uff0c\u6211\u6253\u7b97\u5c06\u5229\u7528Struts\u5f00\u53d1\u7684\u4e00\u5957\u5b8c\u6574\u6d41\u7a0b\u4f5c\u4e3a\u6211\u4eec\u6559\u5b66\u7684\u6848\u4f8b\u3002\u8be5\u6d41\u7a0b\u7684\u8fd9\u4e2a\u6848\u4f8b\u53ef\u8c13\u201c\u9ebb\u96c0\u867d\u5c0f\u3001\u4e94\u810f\u636e\u5168\u201d\uff0c\u4f60\u5b8c\u5168\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u6d41\u7a0b\u5e94\u7528\u5230\u4f60\u624b\u5934\u90a3\u4e9b\u590d\u6742\u5e9e\u5927\u7684\u9879\u76ee\u4e2d\uff0c\u81f3\u5c11\u5728\u6211\u4eec\u7684\u5927\u9879\u76ee\u4e2d\u5e94\u7528\u8fd9\u4e2a\u6d41\u7a0b\u6548\u679c\u4e0d\u9519\u3002<br \/>\n\u6709\u5f00\u53d1\u590d\u6742\u5546\u4e1a\u5e94\u7528\u7684\u5f00\u53d1\u4eba\u5458\u90fd\u77e5\u9053\uff0c\u5ba2\u6237\u7684\u9700\u6c42\u603b\u662f\u5728\u4e0d\u505c\u53d8\u5e7b\uff0c\u6240\u4ee5\u5982\u679c\u6709\u4e00\u5957\u89c4\u8303\u7684\u5f00\u53d1\u6d41\u7a0b\u6765\u9075\u5faa\uff0c\u5f53\u5ba2\u6237\u63d0\u51fa\u65b0\u7684\u9700\u6c42\u65f6\uff0c\u6211\u4eec\u81f3\u5c11\u53ef\u4ee5\u660e\u786e\u54ea\u4e9b\u201c\u65e0\u7406\u201d\u9700\u6c42\u5176\u5b9e\u662f\u5408\u7406\u53ef\u884c\u7684\u3002\u597d\uff0c\u63a5\u4e0b\u91cc\u6211\u5c06\u5728\u6211\u7684\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u5411\u5404\u4f4d\u5c55\u793a\u548c\u5e94\u7528\u6574\u4e2a\u6d41\u7a0b\u3002<br \/>\n\u672c\u6587\u4e2d\u7684\u793a\u4f8b\u4ee3\u7801\u662fStrutsSample\u5e94\u7528\u4e2d\u7684\u4e00\u90e8\u5206\uff0c\u5305\u62ecbuild.xml\u7684\u5b8c\u6574\u4ee3\u7801\u53ef\u4ee5\u5230\u6b64\u5904<a href=\"http:\/\/www.onjava.com\/onjava\/2001\/10\/31\/examples\/StrutsPartII.jar\">http:\/\/www.onjava.com\/onjava\/2001\/10\/31\/examples\/StrutsPartII.jar<\/a>\u4e0b\u8f7d\u3002<br \/>\nStruts\u5f00\u53d1\u8fc7\u7a0b<br \/>\n\u4eceStruts\u53d1\u5e03\u7684\u7248\u672c\u53f7\u53ef\u4ee5\u770b\u51fa\uff0cStruts\u662f\u4e2a\u65b0\u73a9\u610f\uff0c\u5979\u6709\u597d\u51e0\u4e2a\u90e8\u5206\u7ec4\u6210\uff0c\u660e\u667a\u7684\u4f60\u5982\u679c\u641e\u6e05\u695a\u4e86\u4f55\u65f6\u8be5\u5f00\u53d1\u5b8c\u6210\u5408\u9002\u7684\u90e8\u5206\uff0c\u90a3\u5c06\u4f1a\u66f4\u597d\u7684\u5229\u7528\u6211\u4eec\u7684\u5f00\u53d1\u65f6\u95f4\u3002\u4ece\u6211\u6240\u5f00\u53d1\u7684\u51e0\u4e2a\u5229\u7528Struts\u5e94\u7528\u4e2d\uff0c\u6211\u5927\u81f4\u603b\u7ed3\u51fa\u5982\u4e0b\u8fd9\u4e2a\u6bd4\u8f83\u6709\u6548\u7684\u5f00\u53d1\u6b65\u9aa4\uff1a<br \/>\n1\uff0c\u660e\u786e\u5e94\u7528\u9700\u6c42\uff1b<br \/>\n2\uff0c\u7531\u7528\u6237\u8f93\u5165\u548c\u83b7\u53d6\u6570\u636e\u7684\u89d2\u5ea6\u51fa\u53d1\uff0c\u660e\u786e\u548c\u8bbe\u8ba1\u51fa\u6bcf\u4e00\u4e2a\u7528\u6237\u754c\u9762\uff1b<br \/>\n3\uff0c\u786e\u5b9a\u7528\u6237\u754c\u9762\u7684\u8fdb\u5165\u8def\u5f84\uff1b<br \/>\n4\uff0c\u7531\u5e94\u7528\u903b\u8f91\u786e\u5b9a\u52a8\u4f5c\u6620\u5c04\u8868\uff1b<br \/>\n5\uff0c\u7531\u8bbe\u8ba1\u5b8c\u6210\u7684\u7528\u6237\u754c\u9762\u5f00\u53d1\u5176\u6240\u7528\u5230\u7684\u7c7b\u548c\u5e94\u7528\u51fd\u6570\uff1b<br \/>\n6\uff0c\u7531\u7528\u6237\u754c\u9762\u4e2d\u7684\u6570\u636e\u5f00\u53d1ActionForm\u548c\u76f8\u5e94\u7684\u6570\u636e\u6821\u9a8c\u65b9\u6cd5\uff1b<br \/>\n7\uff0cActionMapping\u4e2d\u5c06\u4f1a\u88ab\u8c03\u7528\u76f8\u5e94\u7684Action\u6216\u8f6c\u5230\u76f8\u5e94\u7684JSP\u9875\u9762\uff0c\u8fd9\u4e00\u6b65\u6211\u4eec\u5148\u5f00\u53d1\u8fd9\u4e9bAction\uff1b<br \/>\n8\uff0c\u5f00\u53d1\u5546\u4e1a\u5e94\u7528\u903b\u8f91\uff0c\u5c31\u662f\u76f8\u5e94\u7684JavaBean\u3001EJB\u6216\u5176\u4ed6\u4e1c\u4e1c\uff1b<br \/>\n9\uff0c\u5f00\u53d1\u7531ActionMapping\u5b9a\u4e49\u7684\u7cfb\u7edf\u5de5\u4f5c\u6d41\u7a0b\u5b8c\u6210\u5bf9\u5e94\u7684JSP\u9875\u9762\uff1b<br \/>\n10\uff0c\u5b8c\u6210\u7cfb\u7edf\uff1astruts-config.xml\u548cweb.xml\uff1b<br \/>\n11\uff0c\u7f16\u8bd1\/\u6d4b\u8bd5\/\u53d1\u5e03\u3002<br \/>\n\u660e\u786e\u5e94\u7528\u9700\u6c42<br \/>\n\u5f00\u53d1\u4efb\u4f55\u5e94\u7528\u7cfb\u7edf\u7684\u7b2c\u4e00\u6b65\u5c31\u662f\u6536\u96c6\u7528\u6237\u9700\u6c42\u3002\u4e0d\u7ba1\u4e00\u4e2a\u7528\u6237\u903b\u8f91\u521d\u770b\u4e0a\u53bb\u591a\u4e48\u5408\u7406\uff0c\u4f46\u603b\u6709\u53ef\u80fd\u5728\u5f00\u53d1\u65f6\u624d\u53d1\u73b0\u5b83\u6bd4\u770b\u4e0a\u53bb\u8981\u96be\u5f97\u591a\u3002\u6240\u4ee5\uff0c\u5efa\u8bae\u62df\u4e00\u4efd\u660e\u786e\u7684\u7528\u6237\u9700\u6c42\u5217\u8868\uff0c\u8fd9\u4e0d\u53ea\u662f\u51fa\u4e8e\u5f00\u53d1\u7684\u76ee\u7684\uff0c\u8fd8\u80fd\u901a\u8fc7\u8be5\u8868\u5206\u6790\u7528\u6237\u9700\u6c42\u4ee5\u786e\u5b9a\u54ea\u4e9b\u5730\u65b9\u53ef\u80fd\u9700\u8981\u82b1\u66f4\u591a\u7684\u7cbe\u529b\u3002<br \/>\n\u5728\u6211\u4eec\u8fd9\u4e2aStrutsSample\u9879\u76ee\u4e2d\uff0c\u5e94\u7528\u9700\u6c42\u5c31\u662f\uff1a<br \/>\n\u4f5c\u4e3a\u4e00\u4e2a\u5c55\u793aStruts\u6846\u67b6\u5e94\u7528\u7684\u5b8c\u6574\u4f8b\u5b50\uff0c\u672c\u793a\u4f8b\u5b8c\u6210\u7684\u529f\u80fd\u662f\u7528\u6237\u767b\u5f55\u3002\u76ee\u7684\u53ea\u4e3a\u660e\u786eStruts\u7684\u5e94\u7528\uff0c\u672c\u793a\u4f8b\u5c06\u4e0d\u4f1a\u6d89\u53ca\u5230\u4e00\u822c\u590d\u6742\u5e94\u7528\u7cfb\u7edf\u4e2d\u53ef\u80fd\u5e94\u7528\u7684\u5b89\u5168\u3001\u3001EJB\u5f00\u53d1\u7b49\u7b49\u76f8\u5173\u6280\u672f\u3002<br \/>\n\u8bbe\u8ba1\u7528\u6237\u754c\u9762<br \/>\n\u8fd9\u4e2a\u5e94\u7528\u4e2d\uff0c\u5305\u62ec\u5982\u4e0b\u4e09\u4e2a\u7528\u6237\u754c\u9762\uff1a<br \/>\n1\uff09\u767b\u5f55\u754c\u9762\uff0c\u7528\u4e8e\u7528\u6237\u540d\u548c\u5bc6\u7801\u8f93\u5165\uff1b<br \/>\n2\uff09\u5f53\u767b\u5f55\u7528\u6237\u4e3a\u5408\u6cd5\u7528\u6237\u65f6\u7684\u6b22\u8fce\u754c\u9762\uff1b<br \/>\n3\uff09\u5f53\u767b\u5f55\u5931\u8d25\u65f6\u7684\u9519\u8bef\u63d0\u793a\u754c\u9762\u3002<br \/>\n\u786e\u5b9a\u7528\u6237\u754c\u9762\u7684\u8fdb\u5165\u8def\u5f84<br \/>\n1\uff09\u767b\u5f55\u754c\u9762\u4f5c\u4e3a\u8fd9\u4e2a\u5e94\u7528\u7684\u9ed8\u8ba4\u9875\u9762\uff1b<br \/>\n2\uff09\u6b22\u8fce\u754c\u9762\u53ea\u6709\u5f53\u6210\u529f\u767b\u5f55\u540e\u624d\u80fd\u8fdb\u5165\uff1b<br \/>\n3\uff09\u4efb\u4f55\u53ef\u80fd\u53d1\u751f\u9519\u8bef\u7684\u9875\u9762\u80fd\u53ef\u4ee5\u8fdb\u5165\u9519\u8bef\u63d0\u793a\u754c\u9762\uff1b<br \/>\n\u7531\u5e94\u7528\u903b\u8f91\u786e\u5b9aActionMapping<br \/>\nActionMapping\u4e3a\u6574\u4e2a\u5e94\u7528\u786e\u5b9a\u7684\u201c\u7ebf\u8def\u56fe\u201d\uff0c\u5728\u914d\u7f6e\u6587\u4ef6struts-config.xml\u5bf9ActionMapping\u8fdb\u884c\u5b9a\u4e49\uff0c\u901a\u8fc7\u8f6c\u53d1\u8bf7\u6c42\uff08forward\uff09\u6765\u7406\u987a\u5e94\u7528\u7684\u5904\u7406\u6d41\u7a0b\uff0c\u786e\u5b9a\u5e94\u7528\u4e2d\u6bcf\u4e2a\u7528\u6237\u8bf7\u6c42\u5bf9\u5e94\u7684\u52a8\u4f5c\u3002<br \/>\n\u901a\u5e38\u6211\u4eec\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5c31\u9010\u6b65\u786e\u5b9a\u4e86ActionMapping\u6240\u9700\u7684\uff0c\u5f00\u53d1\u4ee3\u7801\u7684\u8fc7\u7a0b\u5c31\u662f\u5728\u7531\u8349\u7a3f\u5f00\u59cb\u4e00\u6b65\u6b65\u5b8c\u5584struts-config.xml\u7684\u8fc7\u7a0b\u3002\u5f53Action\u7c7b\u5904\u7406\u5b8c\u7528\u6237\u8bf7\u6c42\u540e\uff0c\u5176\u8fd4\u56de\u7684\u7684forward\u5c31\u662f\u5728ActionMapping\u4e2d\u5b9a\u4e49\u7684\u4e00\u4e2a\u3002\u4e00\u4e2aAction\u8fd4\u56de\u7684forward\u5b8c\u5168\u6709\u591a\u79cd\u53ef\u80fd\uff0c\u5c3d\u7ba1\u4e00\u4e2aAction\u4e00\u822c\u53ea\u5b9a\u4e49\u5176\u76f8\u5173\u7684\u51e0\u4e2aforward\u3002\u90a3\u4e48\uff0c\u5982\u679c\u6709\u591a\u4e2aAction\u90fd\u53ef\u80fd\u8fd4\u56de\u7684\u540c\u4e00\u4e2aforward\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u5c06\u5176\u5b9a\u4e49\u4e3a\u5168\u5c40\u8f6c\u53d1\uff08globalforward\uff09\u3002\u8fd9\u7c7b\u4f3c\u4e8eC\u4e2d\u7684\u5934\u6587\u4ef6\u4e2d\u5168\u5c40\u53d8\u91cf\uff0c\u5982\u679c\u5728struts-config.xml\u63cf\u8ff0\u4e2d\uff0c\u67d0\u4e00\u4e2aforward\u5e76\u4e0d\u662f\u5728\u5f53\u524dAction\u63cf\u8ff0\u4e2d\u5b9a\u4e49\u7684\u800c\u662f\u5168\u5c40\u5b9a\u4e49\u7684\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5168\u5c40\u7684\u5c06\u8d77\u4f5c\u7528\uff0c\u540c\u6837\uff0c\u4e00\u4e2aAction\u4e2d\u5f53\u524d\u5b9a\u4e49\u7684forward\u5c06\u8986\u76d6\u5168\u5c40\u5b9a\u4e49\u3002\u5728\u6211\u4eec\u6240\u7ed9\u7684\u8fd9\u4e2a\u7b80\u5355\u5b9e\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u5168\u5c40forward\u2015\u2015\u201cerror\u201d\uff0c\u5f53\u67d0Action\u8fd4\u56de\u7684forward\u662f\u201cerror\u201d\u8fd9\u4e2a\u6620\u5c04\uff0c\u90a3\u4e48Errorpage.jsp\u9875\u9762\u5c06\u4f1a\u663e\u793a\u7ed9\u7528\u6237\uff0c\u5c3d\u7ba1\u5f53\u524dAction\u5e76\u6ca1\u6709\u5bf9\u5176\u5b9a\u4e49\u3002<br \/>\n\u6211\u4eec\u7ee7\u7eed\u4e0d\u65ad\u7684\u5f00\u53d1\uff0c\u9879\u76ee\u65e5\u6e10\u5b8c\u5584\uff0c\u9879\u76ee\u76f8\u5173\u7684\u914d\u7f6e\u6587\u4ef6\u4e5f\u4f1a\u8d8a\u6765\u8d8a\u8be6\u7ec6\u3002\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u4ee5StrutsSample\u4e2d\u7528\u5230\u7684struts-confug.xml\u6587\u4ef6\u4e3a\u4f8b\uff0c\u5b66\u4e60globalforward\u548c\u4e00\u4e2aAction\u4e2d\u76f8\u5173\u6620\u5c04\u7684\u5b9a\u4e49\u3002\u4e0b\u9762\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a\u201clogin\u201d\u7684Action\uff0c\u5176\u4e3acom.oreilly.actions.LoginAction\u7684\u5b9e\u4f8b\uff0c\u5f53Action\u5904\u7406\u7528\u6237\u767b\u5f55\u6210\u529f\u540e\u5c06\u4e00\u4e2a\u540d\u4e3a&#8221;success&#8221;\u7684forward\u8fd4\u56de\uff0c\u7528\u6237\u4e5f\u5c31\u4f1a\u770b\u5230Welcome.jsp\u9875\u9762\uff0c\u5982\u679c\u767b\u5f55\u5931\u8d25\uff0cAction\u5c06\u8fd4\u56de\u5bf9\u5e94\u7684forward\u4ee5\u518d\u663e\u793aLogin.jsp\u7ed9\u7528\u6237\uff0c\u800c\u5982\u679c\u5904\u7406\u8fc7\u7a0b\u4e2d\u53d1\u751f\u5176\u4ed6\u9519\u8bef\uff0cAction\u5c06\u8fd4\u56de\u5168\u5c40\u5b9a\u4e49\u7684forward\u2015\u2015\u201cerror\u201d\uff0c\u7528\u6237\u4e5f\u5c31\u4f1a\u770b\u5230\u9519\u8bef\u63d0\u793a\u9875\u9762Errorpage.jsp\u3002<br \/>\n\u5143\u7d20\u7684\u76f8\u5173\u5c5e\u6027&#8211;&gt;<br \/>\n\u4ee5\u4e0b\u53ea\u5217\u51fa\u5e38\u7528\u5c5e\u6027\uff0c\u5176\u4ed6\u8bf7\u53c2\u8003org.apache.struts.action.ActionMapping\u7684\u76f8\u5173\u6587\u6863<br \/>\npath-\u5f53\u524dAction\u5bf9\u5e94\u7684\u7528\u6237\u8bf7\u6c42URI\u8def\u5f84<br \/>\ntype-\u5b9e\u73b0\u5f53\u524dAction\u7684Javaclass\u7684\u5b8c\u6574\u540d\u5b57<br \/>\nname-\u5f53\u524dAction\u4e2d\u7528\u5230\u7684ActionForm\u7684\u540d\u5b57\uff0c\u5176\u5177\u4f53\u5728\u914d\u7f6e\u6587\u4ef6\u5176\u4ed6\u5730\u65b9\u53e6\u6709\u8be6\u7ec6\u5b9a\u4e49<br \/>\nunknown-\u5982\u679c\u5c06\u8be5\u5c5e\u6027\u8bbe\u7f6e\u4e3atrue\uff0c\u90a3\u4e48\u5c31\u662f\u58f0\u660e\u8fd9\u4e2aAction\u5c06\u5904\u7406\u6574\u4e2a\u5e94\u7528\u4e2d\u6240\u6709\u672a\u627e\u5230\u76f8\u5e94\u5904\u7406Action\u7684\u8bf7\u6c42\uff0c\u5f53\u7136\uff0c\u4e00\u4e2a\u5e94\u7528\u7cfb\u7edf\u4e2d\u4e5f\u53ea\u4f1a\u6709\u4e00\u4e2aAction\u7684unknown\u5c5e\u6027\u53ef\u4ee5\u8bbe\u4e3atrue<br \/>\nscope-Action\u4e2d\u6240\u7528\u5230\u7684ActionForm\u7684\u751f\u5b58\u671f\uff0c\u53ef\u4ee5\u4e3a\u201crequest\u201d\u6216\u201csession\u201d\uff0c\u968f\u7740\u751f\u5b58\u671f\u7684\u8bbe\u7f6e\uff0c\u8be5Action\u4e5f\u4f1a\u5728\u76f8\u5e94\u7684\u65f6\u95f4\u88ab\u521b\u5efa<br \/>\ninput-\u8be5Action\u4e2d\u76f8\u5173ActionForm\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u8f93\u5165\u9875\u9762\uff0c\u5f53\u5c06ActionForm\u8bbe\u4e3a\u81ea\u52a8\u9a8c\u8bc1\u8f93\u5165\u6570\u636e\uff0c\u53d1\u73b0\u4e0d\u5408\u6cd5\u6570\u636e\u8fd4\u56de\u9519\u8bef\u65f6\uff0c\u5c06\u8fd4\u56de\u8be5\u9875\u9762<br \/>\nvalidate-\u5982\u679c\u672c\u5c5e\u6027\u4e3atrue\u5219\u5728Action\u52a8\u4f5c\u4e4b\u524d\u5176\u5bf9\u5e94\u7684ActionForm\u7684validate\u65b9\u6cd5\u4f1a\u81ea\u52a8\u88ab\u8c03\u7528\uff0c\u4e00\u822c\u7528\u4ee5\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u7684\u6570\u636e<br \/>\nforward\u5143\u7d20-\u5b9a\u4e49\u5f53\u524dAction\u76f8\u5173\u7684ActionForward<br \/>\n&#8211;&gt;<br \/>\ntype=&#8221;com.oreilly.actions.LoginAction&#8221;<br \/>\nname=&#8221;loginForm&#8221;<br \/>\nscope=&#8221;request&#8221;<br \/>\ninput=&#8221;\/Login.jsp&#8221;&gt;<br \/>\n\u5728\u524d\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u66fe\u8bf4\u8fc7\uff0cstruts-config.xml\u5c31\u662fMVC\u6a21\u5f0f\u7684\u7684Controller\u3002\u5728\u786e\u5b9astruts-config.xml\u4e2d\u7684\u914d\u7f6e\u65f6\uff0c\u5e94\u8be5\u591a\u82b1\u4e9b\u65f6\u95f4\u7cbe\u529b\u5728\u4e0a\u9762\uff0c\u4ee5\u4fdd\u8bc1\u6bcf\u4e00\u4e2aAction\u5b9a\u4e49\u53ca\u5176\u76f8\u5173\u5b9a\u4e49\u662f\u7b26\u5408\u5e94\u7528\u7684\u9700\u6c42\u7684\u3002\u5982\u679c\u5728\u9879\u76ee\u5f00\u59cb\u6ca1\u6709\u8be6\u7ec6\u7684\u8bbe\u8ba1\u5176\u5b9a\u4e49\uff0c\u5f53\u5c06\u6240\u6709\u4ee3\u7801\u548c\u914d\u7f6e\u96c6\u6210\u5230\u4e00\u8d77\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5c06\u4e0d\u53ef\u907f\u514d\u7684\u5c06\u5404\u90e8\u5206\u7684\u4ee3\u7801\u548c\u914d\u7f6e\u5b8c\u5168\u91cd\u65b0\u7ec4\u7ec7\u4e00\u904d\u3002<br \/>\n\u6211\u4eec\u5f53\u524d\u7684\u4f8b\u5b50StrusSample\u56e0\u4e3a\u53ea\u662f\u5904\u7406\u7528\u6237\u767b\u5f55\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u4e00\u4e2aAction\u3002\u4e00\u4e2a\u5e94\u7528\u7cfb\u7edf\u4e2d\u6240\u8981\u7528\u5230\u7684Action\u7684\u591a\u5c11\u5b8c\u5168\u4f9d\u5e94\u7528\u7684\u5927\u5c0f\u800c\u5b9a\u3002\u4e00\u65e6\u6574\u5957Action\u7684\u6620\u5c04\u5b8c\u5168\u7684\u5b9a\u4e49\u51fa\u6765\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4e00\u4e2a\u4e00\u4e2a\u5f00\u53d1\u5176\u5177\u4f53\u5b9e\u73b0\u7684Action\u548cActionForm\u7c7b\uff0c\u5e76\u9010\u6e10\u5c06\u5b8c\u6210\u7684\u90e8\u5206\u4e00\u70b9\u4e00\u70b9\u96c6\u6210\u8d77\u6765\u3002<br \/>\n\u7531\u8bbe\u8ba1\u5b8c\u6210\u7684\u7528\u6237\u754c\u9762\u5f00\u53d1\u5176\u6240\u7528\u5230\u7684\u7c7b\u548c\u5e94\u7528\u51fd\u6570<br \/>\n\u6240\u6709ActionForm\u7684\u5b9e\u73b0\u7c7b\u90fd\u662forg.apache.struts.ActionForm\u7684\u5b50\u7c7b\u3002\u4e00\u4e2aActionForm\u662f\u4e0e\u9875\u9762\u4e0a\u7684\u8f93\u5165\u8868\u5355\u76f8\u5173\u8054\u7684\uff0c\u800c\u4e14ActionForm\u7684\u5b9e\u73b0\u8fd8\u53ef\u4ee5\u5bf9\u7528\u6237\u8f93\u5165\u6570\u636e\u7684\u5408\u6cd5\u6027\u8fdb\u884c\u9a8c\u8bc1\u3002\u4f5c\u4e3a\u4e00\u4e2aJavaBean\uff0cActionForm\u6709Set\u548cGet\u65b9\u6cd5\uff0c\u5f53\u4e00\u4e2a\u9875\u9762\u4e2d\u8868\u5355\u88ab\u63d0\u4ea4\u65f6\uff0c\u7cfb\u7edf\u5c06\u81ea\u52a8\u8c03\u7528Set\u65b9\u6cd5\u5c06\u6570\u636e\u653e\u5165ActionForm\u4e2d\uff0c\u800cGet\u65b9\u6cd5\u5c06\u4e3a\u5728Action\u4e2d\u64cd\u4f5c\u8fd9\u4e9b\u6570\u636e\u6240\u63d0\u4f9b\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5904\u7406\u8868\u5355\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u5e76\u8fdb\u884c\u5408\u6cd5\u6027\u9a8c\u8bc1\u90fd\u5b8c\u5168\u53ef\u4ee5\u4ea4\u7531ActionForm\u6765\u5b8c\u6210\u3002\u5728\u5e94\u7528\u4e2d\uff0c\u5c31\u6211\u4e2a\u4eba\u800c\u8a00\uff0c\u503e\u5411\u4e8e\u5c06ActionForm\u548cAction\u5212\u5206\u5230\u4e0d\u540c\u7684\u5305\u4e2d\uff0c\u56e0\u4e3a\u5f53\u4e00\u4e2a\u9875\u9762\u4e2d\u8981\u7528\u5230\u51e0\u5bf9ActionFrom\u548cAction\u65f6\uff0c\u90fd\u653e\u5728\u4e00\u4e2a\u5305\u5185\u4f1a\u6df7\u6dc6\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u5728\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u4e00\u6b65\u4e00\u6b65\u7684\u8bb2\u89e3Struts\u7684\u5e94\u7528\uff0c\u4ee5\u8fd9\u6837\u7684\u5f62\u5f0f\u6253\u5f00Struts\u4e00\u9053\u9053\u795e\u79d8\u7684\u5927\u95e8\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u8fc7 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-blog-my-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dongchangbin.net.cn\/?p=103\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"\u6211\u4eec\u5728\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u4e00\u6b65\u4e00\u6b65\u7684\u8bb2\u89e3Struts\u7684\u5e94\u7528\uff0c\u4ee5\u8fd9\u6837\u7684\u5f62\u5f0f\u6253\u5f00Struts\u4e00\u9053\u9053\u795e\u79d8\u7684\u5927\u95e8\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u8fc7 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dongchangbin.net.cn\/?p=103\" \/>\n<meta property=\"og:site_name\" content=\"Dong&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2013-04-27T07:48:49+00:00\" \/>\n<meta name=\"author\" content=\"Dong\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dong\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103\"},\"author\":{\"name\":\"Dong\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae\"},\"headline\":\"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0\",\"datePublished\":\"2013-04-27T07:48:49+00:00\",\"dateModified\":\"2013-04-27T07:48:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103\"},\"wordCount\":200,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae\"},\"articleSection\":[\"Blog my Blog\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dongchangbin.net.cn\/?p=103#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103\",\"url\":\"https:\/\/www.dongchangbin.net.cn\/?p=103\",\"name\":\"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#website\"},\"datePublished\":\"2013-04-27T07:48:49+00:00\",\"dateModified\":\"2013-04-27T07:48:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dongchangbin.net.cn\/?p=103\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/?p=103#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.dongchangbin.net.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#website\",\"url\":\"https:\/\/www.dongchangbin.net.cn\/\",\"name\":\"Dong&#039;s Blog\",\"description\":\"\u6162\u6162\u6765\uff0c\u6bd4\u8f83\u5feb\",\"publisher\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dongchangbin.net.cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae\",\"name\":\"Dong\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3d0ac155d3e1aba6eca6a0a2bb3cdba1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3d0ac155d3e1aba6eca6a0a2bb3cdba1?s=96&d=mm&r=g\",\"caption\":\"Dong\"},\"logo\":{\"@id\":\"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.dongchangbin.net.cn\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dongchangbin.net.cn\/?p=103","og_locale":"zh_CN","og_type":"article","og_title":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog","og_description":"\u6211\u4eec\u5728\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u4e00\u6b65\u4e00\u6b65\u7684\u8bb2\u89e3Struts\u7684\u5e94\u7528\uff0c\u4ee5\u8fd9\u6837\u7684\u5f62\u5f0f\u6253\u5f00Struts\u4e00\u9053\u9053\u795e\u79d8\u7684\u5927\u95e8\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u8fc7 [&hellip;]","og_url":"https:\/\/www.dongchangbin.net.cn\/?p=103","og_site_name":"Dong&#039;s Blog","article_published_time":"2013-04-27T07:48:49+00:00","author":"Dong","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"Dong","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dongchangbin.net.cn\/?p=103#article","isPartOf":{"@id":"https:\/\/www.dongchangbin.net.cn\/?p=103"},"author":{"name":"Dong","@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae"},"headline":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0","datePublished":"2013-04-27T07:48:49+00:00","dateModified":"2013-04-27T07:48:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dongchangbin.net.cn\/?p=103"},"wordCount":200,"commentCount":0,"publisher":{"@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae"},"articleSection":["Blog my Blog"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dongchangbin.net.cn\/?p=103#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dongchangbin.net.cn\/?p=103","url":"https:\/\/www.dongchangbin.net.cn\/?p=103","name":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0 - Dong&#039;s Blog","isPartOf":{"@id":"https:\/\/www.dongchangbin.net.cn\/#website"},"datePublished":"2013-04-27T07:48:49+00:00","dateModified":"2013-04-27T07:48:49+00:00","breadcrumb":{"@id":"https:\/\/www.dongchangbin.net.cn\/?p=103#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dongchangbin.net.cn\/?p=103"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dongchangbin.net.cn\/?p=103#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.dongchangbin.net.cn\/"},{"@type":"ListItem","position":2,"name":"Struts1\u5f00\u53d1\u6d41\u7a0b\u63cf\u8ff0"}]},{"@type":"WebSite","@id":"https:\/\/www.dongchangbin.net.cn\/#website","url":"https:\/\/www.dongchangbin.net.cn\/","name":"Dong&#039;s Blog","description":"\u6162\u6162\u6765\uff0c\u6bd4\u8f83\u5feb","publisher":{"@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dongchangbin.net.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/1420649ce898d888fea55ef4fa6e8fae","name":"Dong","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3d0ac155d3e1aba6eca6a0a2bb3cdba1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3d0ac155d3e1aba6eca6a0a2bb3cdba1?s=96&d=mm&r=g","caption":"Dong"},"logo":{"@id":"https:\/\/www.dongchangbin.net.cn\/#\/schema\/person\/image\/"},"url":"https:\/\/www.dongchangbin.net.cn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/103"}],"collection":[{"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":0,"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dongchangbin.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}