欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
struts2 strus.xml中result類(lèi)型及含義
一個(gè)提交到服務(wù)器的處理通??梢苑譃閮蓚€(gè)階段,第一個(gè)階段查詢(xún)服務(wù)器狀態(tài)(查詢(xún)或者更新數據庫),第二個(gè)階段選擇一個(gè)合適的結果頁(yè)面其返回給用戶(hù)(這里要講的Result的內容)。
Struts2提供了對不同種類(lèi)返回結果的支持,常見(jiàn)的有JSP,FreeMarker,Velocity等。
Struts2支持的不同類(lèi)型的返回結果為:
名字
說(shuō)明
Chain Result
用來(lái)處理Action鏈

Dispatcher Result
用來(lái)轉向頁(yè)面,通常處理JSP

FreeMarker Result
處理FreeMarker模板

HttpHeader Result
用來(lái)控制特殊的Http行為

Redirect Result
重定向到一個(gè)URL

Redirect Action Result
重定向到一個(gè)Action

Stream Result
向瀏覽器發(fā)送InputSream對象,通常用來(lái)處理文件下載

Velocity Result
處理Velocity模板

XLS Result
處理XML/XLST模板

PlainText Result
顯示原始文件內容,例如文件源代碼

S2PLUGINS:Tiles Result
結合Tile使用

另外第三方的Result類(lèi)型還包括JasperReports Plugin,專(zhuān)門(mén)用來(lái)處理JasperReport類(lèi)型的報表輸出。

在struts-default.xml文件中已經(jīng)有了對于所有類(lèi)型Result的定義:

<result-types>

    <result-type name="chain"

             class="com.opensymphony.xwork2.ActionChainResult"/>

    <result-type name="dispatcher"

             class="org.apache.struts2.dispatcher.ServletDispatcherResult"

             default="true"/>

    <result-type name="freemarker"

             class="org.apache.struts2.views.freemarker.FreemarkerResult"/>

    <result-type name="httpheader"

             class="org.apache.struts2.dispatcher.HttpHeaderResult"/>

    <result-type name="redirect"

             class="org.apache.struts2.dispatcher.ServletRedirectResult"/>

    <result-type name="redirectAction"

             class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

    <result-type name="stream"

             class="org.apache.struts2.dispatcher.StreamResult"/>

    <result-type name="velocity"

             class="org.apache.struts2.dispatcher.VelocityResult"/>

    <result-type name="xslt"

             class="org.apache.struts2.views.xslt.XSLTResult"/>

    <result-type name="plainText"

             class="org.apache.struts2.dispatcher.PlainTextResult" />

    <!-- Deprecated name form scheduled for removal in Struts 2.1.0.

         The camelCase versions are preferred. See ww-1707 -->

    <result-type name="redirect-action"

             class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

    <result-type name="plaintext"

             class="org.apache.struts2.dispatcher.PlainTextResult" />

</result-types>
從上述代碼中可以看出在不指定Result類(lèi)型的時(shí)候使用dispatcher類(lèi)型。

定義一個(gè)Result值,

<result name="success" type="dispatcher">

    <param name="location">/ThankYou.jsp</param>

</result>
由于type默認值是dispatcher,所以這里不需要定義,另外name的默認值為success所以這里也不需要定義。
上述代碼可以簡(jiǎn)寫(xiě)為:

<result>

    <param name="location">/ThankYou.jsp</param>

</result>

另外location參數也可以直接卸載result標簽內部,所以上述代碼的最簡(jiǎn)單的寫(xiě)法為:

<result>/ThankYou.jsp</result>

我們也可以定義多個(gè)不同的Result

<action name="Hello">

<result>/hello/Result.jsp</result>

<result name="error">/hello/Error.jsp</result>

<result name="input">/hello/Input.jsp</result>

</action>

上述代碼的含義為,名字為Hello的Action有三個(gè)返回結果,并且都是 dispatcher類(lèi)型(默認類(lèi)型),這三個(gè)返回值的名字分別為success(默認值),error,input(當輸入不通過(guò)時(shí),action 方法返回input),對應的頁(yè)面的路徑分別為 /hello/Result.jsp,/hello/Error.jsp,/hello/Input.jsp。

有些時(shí)候我們需要一個(gè)定義在全局的Result,這個(gè)時(shí)候我們可以在package內部定義全局的Result,例如:

<global-results>

<result name="error">/Error.jsp</result>

<result name="invalid.token">/Error.jsp</result>

<result name="login" type="redirect-action">Logon!input</result>

</global-results>

動(dòng)態(tài)返回結果

有些時(shí)候,只有當Action執行完璧的時(shí)候我們才知道要返回哪個(gè)結果,這個(gè)時(shí)候我們可以在A(yíng)ction內部定義一個(gè)屬性,這個(gè)屬性用來(lái)存儲Action執行完璧之后的Result值,例如:

private String nextAction;

public String getNextAction() {

    return nextAction;

}

在strutx.xml配置文件中,我們可以使用${nextAction}來(lái)引用到Action中的屬性,通過(guò)${nextAction}表示的內容來(lái)動(dòng)態(tài)的返回結果,例如:

<action name="fragment" class="FragmentAction">

<result name="next" type="redirect-action">${nextAction}</result>

</action>
上述Action的execute方法返回next的時(shí)候,還需要根據nextAction的屬性來(lái)判斷具體定位到哪個(gè)Action。


在strutx.xml配置文件中,我們可以使用method=""來(lái)設置調用類(lèi)的哪個(gè)方法,這樣就可以在一個(gè)JAVA類(lèi)中使用不同的方法來(lái)實(shí)現不同的功能,就無(wú)需每個(gè)功能寫(xiě)一類(lèi)了,例如:
<action name="fragment" class="FragmentAction" method="add">
      <result>/success.jsp</result>
</action>
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Struts2配置RESULT中TYPE的參數說(shuō)明
Struts2中struts.xml的Action配置詳解
struts 2 學(xué)習相關(guān)1
struts2中常用Result類(lèi)型的用法
Struts2教程
struts2 result-type 及 參數傳遞
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久