??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲第一视频网,国产成人免费网站,日本电影一区二区http://www.aygfsteel.com/wawlian/category/46067.htmlzh-cnSun, 05 Sep 2010 22:36:31 GMTSun, 05 Sep 2010 22:36:31 GMT60Struts2中result配置中各U视图{发类?/title><link>http://www.aygfsteel.com/wawlian/archive/2010/09/04/331037.html</link><dc:creator>一个h跌</dc:creator><author>一个h跌</author><pubDate>Sat, 04 Sep 2010 06:21:00 GMT</pubDate><guid>http://www.aygfsteel.com/wawlian/archive/2010/09/04/331037.html</guid><wfw:comment>http://www.aygfsteel.com/wawlian/comments/331037.html</wfw:comment><comments>http://www.aygfsteel.com/wawlian/archive/2010/09/04/331037.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wawlian/comments/commentRss/331037.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wawlian/services/trackbacks/331037.html</trackback:ping><description><![CDATA[<span style="font-family: Lucida Console;"><span style="font-family: Lucida Console;">struts2</span>中result常见的几U{发类型:(x)dispatcher(默认)卛_部请求{发,redirect重定向,redirectActionQplainText?br /> 下面分别介绍以下几种方式?br /> <br /> 1.dispatcher方式Q?br />    q种方式是struts2中默认的转发cdQ即内部h转发Q类gforward的方式。这里不专门介绍?br /> <br /> 2.redirect方式Q?br />    首先看一下以下的配置代码片段Q?br /> </span> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"><span style="font-family: Lucida Console;"><span style="color: #008080;">1</span> <span style="color: #0000ff;"><</span><span style="color: #800000;">action </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="redirect"</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">result </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="redirect"</span><span style="color: #0000ff;">></span><span style="color: #000000;">/add.jsp</span><span style="color: #0000ff;"></</span><span style="color: #800000;">result</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #0000ff;"></</span><span style="color: #800000;">action</span><span style="color: #0000ff;">></span></span></span></div> <span style="font-family: Lucida Console;">   q时候,用户在浏览器中访问该actionQ例如,我们输入URLQhttp://localhost:8080/hello/redirect.actionQ当用户开始访问,我们?x)看刎ͼ览器的url地址变成Qhttp://localhost:8080/hello/add.jsp。这说明Q配|的实是浏览器重定向的方式?br /> <br /> 3.redirectAction方式Q?br />    q种方式可以单的理解成{向到另一个Action。这U配|往往在下面的情况下需要用刎ͼ(x)例如Q当理员添加完一个用户后Q系l自动蟩转到用户列表的界面。那么我们进行如下配|:(x)<br /> </span> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"><span style="font-family: Lucida Console;"><span style="color: #008080;">1</span> <span style="color: #0000ff;"><</span><span style="color: #800000;">action </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="redirectAction"</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">result </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="redirectAction"</span><span style="color: #0000ff;">></span><span style="color: #000000;">listAction</span><span style="color: #0000ff;"></</span><span style="color: #800000;">result</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #0000ff;"></</span><span style="color: #800000;">action</span><span style="color: #0000ff;">></span></span></span></div>     而其中的listAction是用来控制显C所有用L(fng)action。ƈ且,该action必须和redirectAction处在同一个package下面。那么如果不在同一个包下,则需q行如下配置Q?br /> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"><span style="font-family: Lucida Console;"><span style="color: #008080;">1</span> <span style="color: #0000ff;"><</span><span style="color: #800000;">result </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="redirectAction"</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">param </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="actionName"</span><span style="color: #0000ff;">></span><span style="color: #000000;">XXX</span><span style="color: #0000ff;"></</span><span style="color: #800000;">param</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">param </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="namespace"</span><span style="color: #0000ff;">></span><span style="color: #000000;">YYY</span><span style="color: #0000ff;"></</span><span style="color: #800000;">param</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #0000ff;"></</span><span style="color: #800000;">result</span><span style="color: #0000ff;">></span></span></span></div>     其中XXX代表你要转向到的Action的名UͼYYY代表该Action所在package对应的名U空间?br /> <br /> <span style="font-family: Lucida Console;">4.plainText方式</span><br />     q种方式一般来说用的比较?yu),可能用到的情况?x)原样输出源代码。配|如下:(x)<br /> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;"><span style="font-family: Lucida Console;"><span style="color: #008080;">1</span> <span style="color: #0000ff;"><</span><span style="color: #800000;">action </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="abc"</span><span style="color: #ff0000;"> </span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"><</span><span style="color: #800000;">result </span><span style="color: #ff0000;">type</span><span style="color: #0000ff;">="plainText"</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">        </span><span style="color: #0000ff;"><</span><span style="color: #800000;">param </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="location"</span><span style="color: #0000ff;">></span><span style="color: #000000;">/index.jsp</span><span style="color: #0000ff;"></</span><span style="color: #800000;">param</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;">        </span><span style="color: #0000ff;"><</span><span style="color: #800000;">param </span><span style="color: #ff0000;">name</span><span style="color: #0000ff;">="charSet"</span><span style="color: #0000ff;">></span><span style="color: #000000;">UTF-8</span><span style="color: #0000ff;"></</span><span style="color: #800000;">param</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;">    </span><span style="color: #0000ff;"></</span><span style="color: #800000;">result</span><span style="color: #0000ff;">></span><span style="color: #000000;"><br /> </span><span style="color: #008080;">6</span> <span style="color: #0000ff;"></</span><span style="color: #800000;">action</span><span style="color: #0000ff;">></span></span></span></div>    q时Qindex.jsp的源代码则会(x)以文本方式显C在览器中?br /> <br /> <span style="font-family: Lucida Console;"><br /> </span> <img src ="http://www.aygfsteel.com/wawlian/aggbug/331037.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wawlian/" target="_blank">一个h跌</a> 2010-09-04 14:21 <a href="http://www.aygfsteel.com/wawlian/archive/2010/09/04/331037.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Action中各w|的默认?/title><link>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330091.html</link><dc:creator>一个h跌</dc:creator><author>一个h跌</author><pubDate>Fri, 27 Aug 2010 13:20:00 GMT</pubDate><guid>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330091.html</guid><wfw:comment>http://www.aygfsteel.com/wawlian/comments/330091.html</wfw:comment><comments>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330091.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wawlian/comments/commentRss/330091.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wawlian/services/trackbacks/330091.html</trackback:ping><description><![CDATA[配置一个ActionQ?br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><span style="color: #008080">1</span><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">package </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="hello"</span><span style="color: #ff0000"> namespace</span><span style="color: #0000ff">="/action"</span><span style="color: #ff0000"> extends</span><span style="color: #0000ff">="struts-default"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">2</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">action </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="helloworld"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">3</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">result</span><span style="color: #0000ff">></span><span style="color: #000000">/WEB-INF/page/hello.jsp</span><span style="color: #0000ff"></</span><span style="color: #800000">result</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">4</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">action</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">5</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff"></</span><span style="color: #800000">package</span><span style="color: #0000ff">></span></div> Action的代码如下:(x)<br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><span style="color: #008080"> 1</span><img id="Codehighlighter1_30_178_Open_Image" onclick="this.style.display='none'; Codehighlighter1_30_178_Open_Text.style.display='none'; Codehighlighter1_30_178_Closed_Image.style.display='inline'; Codehighlighter1_30_178_Closed_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" alt="" /><img style="display: none" id="Codehighlighter1_30_178_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_30_178_Closed_Text.style.display='none'; Codehighlighter1_30_178_Open_Image.style.display='inline'; Codehighlighter1_30_178_Open_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" alt="" /><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> HelloWorldAction </span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_30_178_Closed_Text"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_30_178_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 2</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />    </span><span style="color: #0000ff">private</span><span style="color: #000000"> String msg;<br /> </span><span style="color: #008080"> 3</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />    <br /> </span><span style="color: #008080"> 4</span><span style="color: #000000"><img id="Codehighlighter1_83_100_Open_Image" onclick="this.style.display='none'; Codehighlighter1_83_100_Open_Text.style.display='none'; Codehighlighter1_83_100_Closed_Image.style.display='inline'; Codehighlighter1_83_100_Closed_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" /><img style="display: none" id="Codehighlighter1_83_100_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_83_100_Closed_Text.style.display='none'; Codehighlighter1_83_100_Open_Image.style.display='inline'; Codehighlighter1_83_100_Open_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String getMessage() </span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_83_100_Closed_Text"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_83_100_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 5</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> msg;<br /> </span><span style="color: #008080"> 6</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" />    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" /><br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img id="Codehighlighter1_127_176_Open_Image" onclick="this.style.display='none'; Codehighlighter1_127_176_Open_Text.style.display='none'; Codehighlighter1_127_176_Closed_Image.style.display='inline'; Codehighlighter1_127_176_Closed_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" /><img style="display: none" id="Codehighlighter1_127_176_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_127_176_Closed_Text.style.display='none'; Codehighlighter1_127_176_Open_Image.style.display='inline'; Codehighlighter1_127_176_Open_Text.style.display='inline';" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" alt="" />    </span><span style="color: #0000ff">public</span><span style="color: #000000"> String execute()</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_127_176_Closed_Text"><img src="http://www.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_127_176_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />        msg </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">我的W一个struts2应用</span><span style="color: #000000">"</span><span style="color: #000000">;<br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">success</span><span style="color: #000000">"</span><span style="color: #000000">;<br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" alt="" />    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" alt="" />}</span></span></div> 讉K以下路径Q?a href="http://localhost:8080/struts2/action/helloworld">http://localhost:8080/struts2/action/helloworld</a>依然可以讉K到jsp中的内容。这主要是因为Action中有很多默认配置Q?br /> 1.如果没有为action配置class属性,那么光认gؓ(f)ActionSupport?br /> 2.如果没有为action配置method属性,那么默认为execute<br /> 3.ActionSupportcM有一个execute()Ҏ(gu)Q它q回一个常量SUCCESSQ而该帔R的gؓ(f)"success"?br /> 4.如果没有为result讄name属性,默认为success?br /> 知道以上内容Q则不难理解Z么即使省略了很多属性的配置Q依然能够访问到该Action了? <img src ="http://www.aygfsteel.com/wawlian/aggbug/330091.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wawlian/" target="_blank">一个h跌</a> 2010-08-27 21:20 <a href="http://www.aygfsteel.com/wawlian/archive/2010/08/27/330091.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts2对Action名称的搜索顺?/title><link>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330090.html</link><dc:creator>一个h跌</dc:creator><author>一个h跌</author><pubDate>Fri, 27 Aug 2010 13:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330090.html</guid><wfw:comment>http://www.aygfsteel.com/wawlian/comments/330090.html</wfw:comment><comments>http://www.aygfsteel.com/wawlian/archive/2010/08/27/330090.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wawlian/comments/commentRss/330090.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wawlian/services/trackbacks/330090.html</trackback:ping><description><![CDATA[新徏一个struts2目Q命名ؓ(f)struts2。按照如下XML文g配置一个ActionQ?br /> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><span style="color: #008080">1</span><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">package </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="hello"</span><span style="color: #ff0000"> namespace</span><span style="color: #0000ff">="/action"</span><span style="color: #ff0000"> extends</span><span style="color: #0000ff">="struts-default"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">2</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">action </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="helloworld"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="com.xiaobai.struts.action.HelloWorldAction"</span><span style="color: #ff0000"> method</span><span style="color: #0000ff">="execute"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">3</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">result </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="success"</span><span style="color: #0000ff">></span><span style="color: #000000">/WEB-INF/page/hello.jsp</span><span style="color: #0000ff"></</span><span style="color: #800000">result</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">4</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">action</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> </span><span style="color: #008080">5</span><span style="color: #000000"><img align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" alt="" /></span><span style="color: #0000ff"></</span><span style="color: #800000">package</span><span style="color: #0000ff">></span></div> 应用部|Ԍ讉K如下路径Q?a href="http://localhost:8080/struts2/action/sdf/dsf/32/d/helloworld">http://localhost:8080/struts2/action/sdf/dsf/32/d/helloworld</a> 依然可以讉K到Action?br /> q主要是因ؓ(f)Struts2对Action名称的搜索是按照一定顺序进行的。以上面的情况ؓ(f)例:(x)<br /> 1.struts2首先搜烦命名I间?action/sdf/dsf/32/d的包是否存在Q存在的情况下,是否有helloworldq个ActionQ?br /> 2.搜烦命名I间?action/sdf/dsf/32的包是否存在Q存在的情况下,是否有helloworldq个ActionQ?br /> 3.搜烦命名I间?action/sdf/dsf的包是否存在Q存在的情况下,是否有helloworldq个ActionQ?br /> 4.搜烦命名I间?action/sdf的包是否存在Q存在的情况下,是否有helloworldq个ActionQ?br /> 5.搜烦命名I间?action的包是否存在。在q种情况下能够搜索到Q因此,可以讉K到helloworldq个Action?br /> 此外Q如果按照这U搜索顺序搜索,发现所有的包均不存在,那么struts2则会(x)到命名空间ؓ(f)""Q默认命名空_(d)的包下面Lhelloworldq个Action? <img src ="http://www.aygfsteel.com/wawlian/aggbug/330090.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wawlian/" target="_blank">一个h跌</a> 2010-08-27 21:02 <a href="http://www.aygfsteel.com/wawlian/archive/2010/08/27/330090.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts2的第一个应?hello world)Q根据传智播客相兌频整理)http://www.aygfsteel.com/wawlian/archive/2010/08/26/330009.html一个h跌一个h跌Thu, 26 Aug 2010 13:16:00 GMThttp://www.aygfsteel.com/wawlian/archive/2010/08/26/330009.htmlhttp://www.aygfsteel.com/wawlian/comments/330009.htmlhttp://www.aygfsteel.com/wawlian/archive/2010/08/26/330009.html#Feedback0http://www.aygfsteel.com/wawlian/comments/commentRss/330009.htmlhttp://www.aygfsteel.com/wawlian/services/trackbacks/330009.html1.新徏一个web目Q取名ؓ(f)struts2.
2.加入struts2的相关jar文gQ将struts.xml文g拯qsrc目录下。将修改q的web.xml文g拯至struts2/WebRoot/WEB-INF/下?br /> 3.新徏一个ActionQHelloWorldAction。其代码如下Q?/p>
 1package com.xiaobai.struts.action;
 2
 3public class HelloWorldAction {
 4    private String msg;
 5    
 6    public String getMessage() {
 7        return msg;
 8    }

 9
10    public String execute(){
11        msg = "我的W一个struts2应用";
12        return "success";
13    }

14}
4.修改strut.xml文gQ在<struts></struts>标签对中加入以下配置Q?br />
1<package name="hello" namespace="/action" extends="struts-default">
2    <action name="helloworld" class="com.xiaobai.struts.action.HelloWorldAction" method="execute">
3    <result name="success">/WEB-INF/page/hello.jsp</result>
4    </action>
5</package>

5.部v该项目。ƈ且启动Tomcat服务器,讉Khttp://localhost:8080/struts2/action/helloworld
看到如下图所C的l果Q?br />

下面对写的代码及配置做一点解释:(x)
1.<package>标签的namespace属性可以作为action讉K路径的一部分。不讄该属性或其讄?"Q空字符Ԍ则ؓ(f)默认命名I间。例如上面的package属性设|ؓ(f)"/action"Qaction标签的name属性设|ؓ(f)"helloworld"Q所以访问该action的\径应?action/helloworldQ这也就是上面这个应用的讉K地址?a href="http://localhost:8080/struts2/action/helloworld">http://localhost:8080/struts2/action/helloworld的原因?br /> 2.一般情况下Qpackage都应当承自struts-default包,卻Ipackage的extends属性设|ؓ(f)"struts-default"Q这h能获得struts2的许多功能?br /> 3.action的method属性主要是定义请求交laction中的哪个Ҏ(gu)来处理?br /> 4.result标签中的name属性值对应action中的处理Ҏ(gu)(q里是executeҎ(gu))的返回|用来定义在该q回值的情况下如何进行{向?br />    上面的应用中的jsp文g攄在WEB-INF文g下,主要是ؓ(f)了不让用L(fng)接访问到jsp面Q而是通过讉Ka(chn)ctionQƈ通过action的控制来讉K信息?br />    (psQ用L(fng)接访问jsp文g也无法获得msg的?


一个h跌 2010-08-26 21:16 发表评论
]]>
Struts2开发环境搭?/title><link>http://www.aygfsteel.com/wawlian/archive/2010/08/26/329959.html</link><dc:creator>一个h跌</dc:creator><author>一个h跌</author><pubDate>Thu, 26 Aug 2010 05:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/wawlian/archive/2010/08/26/329959.html</guid><wfw:comment>http://www.aygfsteel.com/wawlian/comments/329959.html</wfw:comment><comments>http://www.aygfsteel.com/wawlian/archive/2010/08/26/329959.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/wawlian/comments/commentRss/329959.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/wawlian/services/trackbacks/329959.html</trackback:ping><description><![CDATA[<p><span style="font-family: Comic Sans MS"><span style="font-family: Courier">struts2开发环境的搭徏主要涉及以下三个步骤Q?br /> 1.扑ֈ开发struts2应用需要的jar文g?br /> 2.~写struts2的配|文件?br /> 3.修改web.xml文g?br /> 具体步骤如下Q?br /> 1.?a >http://struts.apache.org/</a>下蝲struts。下载完成之后将下蝲的zip文g解压?br /> 2.在MyEclipse中创Z个web目Q给目命名Q例如,struts2.<br /> 3.q入struts解压目录下的lib目录中,扑ֈ以下jar文g(版本号可能不?Q?br />   struts2-core-2.x.x.jar<br />   xwork-2.x.x.jar<br />   ognl-2.6.x.jar<br />   freemarker-2.3.x.jar<br />   commons-logging-1.1.x.jar<br />   commons-fileupload-1.2.x.jar<br />   这些jar文g拯x建的web目的WEB-INF/lib目录下。这些jar文g时开发struts2应用需要的最的jar文g集合?br /> 4.在项目的src目录下新建或者从别处拯一个struts.xml。该文g是struts2的配|文件。该文g可以通过以下方式获得Q?br />   在struts的解压目录下的apps目录下有一些struts2的示例应用。例如,struts2-blank-2.1.8.1.war。用WinRAR其解压~,在解压目?br />   下的WEB-INF/classes目录下,扑ֈstruts.xmlQ将其复制到目的src目录下,打开该文Ӟ?lt;struts></struts>标签对中的其他内?br />   删除?br /> 5.修改web.xml文g。进入解压的strutsCZ应用Q将WEB-INF目录下的web.xml文g拯替换目中的web.xml文g卛_?br />   或者也可以在项目中的struts.xml文g中添加一个Filter的配|:(x)<br /> </p> <div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" /><span style="color: #0000ff"><</span><span style="color: #800000">filter</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">filter-name</span><span style="color: #0000ff">></span><span style="color: #000000">struts2</span><span style="color: #0000ff"></</span><span style="color: #800000">filter-name</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">filter-class</span><span style="color: #0000ff">></span><span style="color: #000000">org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</span><span style="color: #0000ff"></</span><span style="color: #800000">filter-class</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff"></</span><span style="color: #800000">filter</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" /><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff"><</span><span style="color: #800000">filter-mapping</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">filter-name</span><span style="color: #0000ff">></span><span style="color: #000000">struts2</span><span style="color: #0000ff"></</span><span style="color: #800000">filter-name</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">url-pattern</span><span style="color: #0000ff">></span><span style="color: #000000">/*</span><span style="color: #0000ff"></</span><span style="color: #800000">url-pattern</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" align="top" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" /></span><span style="color: #0000ff"></</span><span style="color: #800000">filter-mapping</span><span style="color: #0000ff">></span></div> <p>q样Qstruts2的开发环境就搭徏好了?br /> Q以上内Ҏ(gu)据传智播客的相关视频整理Q主要是方便自己以后查看Q?/span></span></p> <img src ="http://www.aygfsteel.com/wawlian/aggbug/329959.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/wawlian/" target="_blank">一个h跌</a> 2010-08-26 13:04 <a href="http://www.aygfsteel.com/wawlian/archive/2010/08/26/329959.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӫɽ</a>| <a href="http://" target="_blank">¯</a>| <a href="http://" target="_blank">ԭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">֦</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank">Ƶ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɯ</a>| <a href="http://" target="_blank">ʯ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽʡ</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">Ϲ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ѧ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">齭</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>