{"id":1646,"date":"2017-07-14T16:51:51","date_gmt":"2017-07-14T08:51:51","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=1646"},"modified":"2017-07-14T16:51:51","modified_gmt":"2017-07-14T08:51:51","slug":"servlet%e8%bd%ac%e5%8f%91%e6%8e%a7%e5%88%b6%e5%99%a8servletforwardingcontroller","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=1646","title":{"rendered":"Servlet\u8f6c\u53d1\u63a7\u5236\u5668(ServletForwardingController)"},"content":{"rendered":"<p>\n\tSpring MVC \u4e2d\u6709\u5f88\u591a\u63a7\u5236\u5668\uff0c\u672c\u7ae0\u5c06\u91cd\u70b9\u8bb2\u89e3ServletForwardingController\u63a7\u5236\u5668\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Spring MVC \u4e2d\u7684\u63a7\u5236\u5668\" src=\"http:\/\/img.my.csdn.net\/uploads\/201010\/10\/0_12867138104Lkq.gif\" style=\"width: 843px;height: 620px\" \/>\n<\/p>\n<p>\n\t\u4ece\u4e0a\u56fe\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0cSpring MVC \u4e2d\u670914\u4e2a\u63a7\u5236\u5668\u3002\n<\/p>\n<h2>\n\tServlet\u8f6c\u53d1\u63a7\u5236\u5668(ServletForwardingController)<br \/>\n<\/h2>\n<p>\n\tServlet\u5305\u88c5\u63a7\u5236\u5668\u5c06\u6240\u6709\u7684HTTP\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u4e00\u4e2a\u5728web.xml\u4e2d\u5b9a\u4e49\u7684Servlet\u3002Web\u5bb9\u5668\u4f1a\u5bf9\u8fd9\u4e2a\u5b9a\u4e49\u5728web.xml\u7684\u6807\u51c6Servlet\u8fdb\u884c\u521d\u59cb\u5316\u548c\u6790\u6784\u3002\n<\/p>\n<p>\n\tServletForwardingController\u5c06\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230\u4e00\u4e2a\u547d\u540d\u7684servlet\uff0c\u5177\u4f53\u793a\u4f8b\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npackage com.xttblog.web.servlet;  \r\npublic class ForwardingServlet extends HttpServlet {      \r\n    @Override  \r\n    protected void doGet(HttpServletRequest req, HttpServletResponse resp)  \r\n\t\tthrows ServletException, IOException {  \r\n        resp.getWriter().write(&quot;Controller forward to Servlet&quot;);  \r\n    }  \r\n} <\/pre>\n<pre class=\"brush:xml;\">\r\n&lt;servlet&gt;  \r\n    &lt;servlet-name&gt;forwarding&lt;\/servlet-name&gt;  \r\n    &lt;servlet-class&gt;com.xttblog.web.servlet.ForwardingServlet&lt;\/servlet-class&gt;  \r\n&lt;\/servlet&gt; <\/pre>\n<pre class=\"brush:xml;\">\r\n&lt;!&mdash; \u5728chapter4-servlet.xml\u914d\u7f6e\u5904\u7406\u5668 --&gt;     \r\n&lt;bean name=&quot;\/forwardToServlet&quot;   \r\n\tclass=&quot;org.springframework.web.servlet.mvc.ServletForwardingController&quot;&gt;  \r\n        &lt;property name=&quot;servletName&quot; value=&quot;forwarding&quot;&gt;&lt;\/property&gt;  \r\n&lt;\/bean&gt;<\/pre>\n<p>\n\t\u5f53\u6211\u4eec\u8bf7\u6c42\/forwardToServlet\u65f6\uff0c\u4f1a\u88ab\u8f6c\u53d1\u5230\u540d\u5b57\u4e3a&ldquo;forwarding&rdquo;\u7684servlet\u5904\u7406\uff0c\u8be5sevlet\u7684servlet-mapping\u6807\u7b7e\u914d\u7f6e\u662f\u53ef\u9009\u7684\u3002\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height:26px;width:523px\">\n<tbody>\n<tr>\n<td style=\"width:184px;height:18px\">\n<p>\n\t\t\t\t\t<strong><em>Servlet<\/em><\/strong><strong><em>\u5c01\u88c5\u5bf9\u8c61<\/em><\/strong>\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:134px;height:18px\">\n<p>\n\t\t\t\t\t<strong><em>\u7ba1\u7406\u8303\u56f4<\/em><\/strong>\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:101px;height:18px\">\n<p>\n\t\t\t\t\t<strong><em>\u521d\u59cb\u5316\u548c\u6790\u6784<\/em><\/strong>\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:103px;height:18px\">\n<p>\n\t\t\t\t\t<strong><em>\u670d\u52a1\u8c03\u7528\u65b9\u5f0f<\/em><\/strong>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width:184px;height:18px\">\n<p>\n\t\t\t\t\tSimpleServletHandlerAdaptor\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:134px;height:18px\">\n<p>\n\t\t\t\t\tWeb\u5e94\u7528\u7a0b\u5e8f\u73af\u5883\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:101px;height:18px\">\n<p>\n\t\t\t\t\t\u6ca1\u6709\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:103px;height:18px\">\n<p>\n\t\t\t\t\t\u76f4\u63a5\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width:184px;height:18px\">\n<p>\n\t\t\t\t\tServletWrappingController\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:134px;height:18px\">\n<p>\n\t\t\t\t\t\u63a7\u5236\u5668\u5185\u90e8\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:101px;height:18px\">\n<p>\n\t\t\t\t\t\u6709\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:103px;height:18px\">\n<p>\n\t\t\t\t\t\u76f4\u63a5\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width:184px;height:18px\">\n<p>\n\t\t\t\t\tServletForwardingController\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:134px;height:18px\">\n<p>\n\t\t\t\t\tweb.xml\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:101px;height:18px\">\n<p>\n\t\t\t\t\t\u6709\n\t\t\t\t<\/p>\n<\/td>\n<td style=\"width:103px;height:18px\">\n<p>\n\t\t\t\t\tServlet\u6d3e\u9063\u5668\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\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=1646\">Servlet\u8f6c\u53d1\u63a7\u5236\u5668(ServletForwardingController)<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Spring MVC \u4e2d\u6709\u5f88\u591a\u63a7\u5236\u5668\uff0c\u672c\u7ae0\u5c06\u91cd\u70b9\u8bb2\u89e3ServletForwardingController\u63a7\u5236 [&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":[1372,1373,1350,1359],"class_list":["post-1646","post","type-post","status-publish","format-standard","hentry","category-java","tag-servletforwardingcontroller","tag-servlet","tag-spring-mvc","tag-spring-mvc-"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1646","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=1646"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1646\/revisions"}],"predecessor-version":[{"id":1647,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1646\/revisions\/1647"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}