struts2几种result type探究
http://blog.csdn.net/hzzhoushaoyu/article/details/6765926
可以在struts2-core-{version}.jar中找到struts-default.xml,里面列舉了當前可以使用的所有result-type以及對應的class
此處是struts2.2.3的
[html]?view plaincopyprint?
1.chain
該類型是請求轉發給其他的action,如果為jsp則會報錯
需要注意的就是與redirect的區別,請求轉發是還在當前請求,
而redirect會響應一次瀏覽器然后瀏覽器再根據響應請求重定向的資源,注意看url的變化就明白了!
下面是apache給的示例,這個比較簡單,沒什么說的,
<span class="code-tag"></span><div class="dp-highlighter bg_html" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 936.53125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153);"><strong>[html]</strong> <a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">view plain</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">copy</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">print</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">?</a><div style="position: absolute; left: 483px; top: 957px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-xml" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">package</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"public"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">extends</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"struts-default"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="comments" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;"><!--?Chain?creatAccount?to?login,?using?the?default?parameter?--></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"createAccount"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"..."</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">type</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"chain"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">login</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"login"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"..."</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="comments" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;"><!--?Chain?to?another?namespace?--></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">type</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"chain"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"actionName"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">dashboard</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"namespace"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">/secure</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">package</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">package</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"secure"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">extends</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"struts-default"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">namespace</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"/secure"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"dashboard"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"..."</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">dashboard.jsp</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">package</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li></ol></div> <strong><span style="font-size: 16px;">2.dispatcher</span></strong> 請求轉發視圖資源,比如jsp,html,如果請求action會找不到資源, 請求轉發的問題看1中的說明 apache給的示例。。也沒啥說的 <div class="dp-highlighter bg_html" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 936.53125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153);"><strong>[html]</strong> <a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">view plain</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">copy</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">print</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">?</a><div style="position: absolute; left: 483px; top: 1512px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-xml" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"success"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">type</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"dispatcher"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"location"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">foo.jsp</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li></ol></div> <strong><span style="font-size: 16px;">3.httpheader</span></strong> 這個挺有意思的,可以隨便更改響應狀態 比如下面的這個示例 <div class="dp-highlighter bg_html" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 936.53125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153);"><strong>[html]</strong> <a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">view plain</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">copy</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">print</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">?</a><div style="position: absolute; left: 483px; top: 1735px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-xml" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"test"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">class</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"com.iss.action.TestAction"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"success"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">type</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"httpheader"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"><</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="attribute" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">name</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">=</span><span class="attribute-value" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit;">"status"</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">400</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">param</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">result</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????<span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;"></</span><span class="tag-name" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">action</span><span class="tag" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">></span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li></ol></div> 當action返回SUCCESS的時候,會將響應狀態修改為400,客戶端錯誤的請求, 還有其他的狀態可以自行嘗試,比如為100時,瀏覽器會在請求一段時間之后繼續當前頁面,500則為服務器內部錯誤等等 具體為什么會產生這樣的結果,當然得把源碼翻出來了 下面是HttpHeaderResult的一些成員變量,private的可以作為param的name屬性 <div class="dp-highlighter bg_java" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 936.53125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153);"><strong>[java]</strong> <a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">view plain</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">copy</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">print</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">?</a><div style="position: absolute; left: 483px; top: 2020px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-j" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">static</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">final</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">long</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?serialVersionUID?=?195648957144219214L;??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">/**?The?default?parameter?*/</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">static</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">final</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?String?DEFAULT_PARAM?=?</span><span class="string" style="margin: 0px; padding: 0px; border: none; color: red; background-color: inherit;">"status"</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">boolean</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?parse?=?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">true</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?Map<String,String>?headers;??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?status?=?-</span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">1</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">int</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?error?=?-</span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">1</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">;??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">private</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?String?errorMessage;??</span></span></li></ol></div> 下面是具體執行操作過程,可以看到response.setStatus等操作<div class="dp-highlighter bg_java" style="font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: rgb(231, 229, 220); width: 936.53125px; overflow: auto; padding-top: 1px; margin: 18px 0px !important;"><div class="bar" style="padding-left: 45px;"><div class="tools" style="padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; background-color: rgb(248, 248, 248); border-left-width: 3px; border-left-style: solid; border-left-color: rgb(153, 153, 153);"><strong>[java]</strong> <a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="ViewSource" title="view plain" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">view plain</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="CopyToClipboard" title="copy" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">copy</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="PrintSource" title="print" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">print</a><a target=_blank href="http://blog.csdn.net/hzzhoushaoyu/article/details/6765926#" class="About" title="?" style="color: rgb(160, 160, 160); text-decoration: none; background-image: none; background-color: inherit; border: none; padding: 0px; margin: 0px 10px 0px 0px; font-size: 9px; background-position: initial initial; background-repeat: initial initial;">?</a><div style="position: absolute; left: 483px; top: 2361px; width: 29px; height: 14px; z-index: 99;"></div></div></div><ol start="1" class="dp-j" style="padding: 0px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); margin: 0px 0px 1px 45px !important;"><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">public</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">void</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?execute(ActionInvocation?invocation)?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">throws</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?Exception?{??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????HttpServletResponse?response?=?ServletActionContext.getResponse();??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????ValueStack?stack?=?ActionContext.getContext().getValueStack();??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??????????</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?(status?!=?-</span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">1</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)?{??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????response.setStatus(status);??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????}?<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">else</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?(error?!=?-</span><span class="number" style="margin: 0px; padding: 0px; border: none; color: rgb(192, 0, 0); background-color: inherit;">1</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)?{??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?(errorMessage?!=?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">null</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)?{??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????String?finalMessage?=?parse???TextParseUtil.translateVariables(??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????????errorMessage,?stack)?:?errorMessage;??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????response.sendError(error,?finalMessage);??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????}?<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">else</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????response.sendError(error);??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????}??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">if</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?(headers?!=?</span><span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">null</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">)?{??</span></span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????<span class="keyword" style="margin: 0px; padding: 0px; border: none; color: blue; background-color: inherit; font-weight: bold;">for</span><span style="margin: 0px; padding: 0px; border: none; background-color: inherit;">?(Iterator?iterator?=?headers.entrySet().iterator();??</span></span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">?????????????????iterator.hasNext();)?{??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????Map.Entry?entry?=?(Map.Entry)?iterator.next();??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????String?value?=?(String)?entry.getValue();??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????String?finalValue?=?parse???TextParseUtil.translateVariables(value,?stack)?:?value;??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????????response.addHeader((String)?entry.getKey(),?finalValue);??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????????}??</span></li><li style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: rgb(85, 85, 85); line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????????}??</span></li><li class="alt" style="margin: 0px !important; padding: 0px 3px 0px 10px !important; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(153, 153, 153); list-style: decimal-leading-zero outside; background-color: rgb(245, 250, 226); color: inherit; line-height: 18px;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">????}??</span></li></ol></div> <strong><span style="font-size: 16px;">4.redirect </span></strong>
重定向操作,與請求轉發的區別看1的介紹
讓客戶端請求另外的網絡資源,可以為action,也可以為視圖資源
下面是apache的示例
[html]?view plaincopyprint?
重定向至Action,與redirect的區別找了好久,但是也沒發現比較權威的說明
最明顯的區別當然是redirectAction只能請求action,如果請求視圖資源會報錯
然后還有個小區別就是redirectAction會為url添加.action后綴而redirect不會
有說redirectAction無法通過url傳參,但是我測試時完全可以通過request獲取到,
此處區別如果有哪位知道的麻煩告知,Thank you!
下面是apache的傳參的示例
[html]?view plaincopyprint?
6.stream
這個返回類型主要用作下載文件或者在瀏覽器上顯示PDF等文檔
此處給一個顯示PDF文檔示例
項目web.xml中
[html]?view plaincopyprint?
struts.xml中
[html]?view plaincopyprint?
TestAction.java中
[java]?view plaincopyprint?
7.plainText
響應以plain形式返回給客戶端
截取源碼的最重要的一部分
[java]?view plaincopyprint?
8.freemarker,velocity,xslt
沒有嘗試過,有興趣的可以嘗試下
寫得很累。。。
轉載請注明出處:http://blog.csdn.net/zhouyuqwert/article/details/6765926
總結
以上是生活随笔為你收集整理的struts2几种result type探究的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: struts2 去掉或修改后缀名
- 下一篇: Servlet异常处理