result告訴struts2框架, 當(dāng)Action處理結(jié)束后,系統(tǒng)下一步做什么。
Struts2提供了兩種配置方式,
全局結(jié)果:<result>作為<global-results>的子元素配置
局部結(jié)果:<result>作為<action>的子元素配置
局部結(jié)果的屬性 name,type,location,parse.
parse默認(rèn)值為true,指定是否可以在實際視圖名字中使用OGNL表達(dá)式。
type默認(rèn)值為dispatcher.
struts2內(nèi)建的結(jié)果類型,在struts-default.xml中定義的.
chain ,dispatcher,freemaker,httpheader,redirect,redirect-action,stream,velocity,xslt,plainText。
plainText結(jié)果類型:將結(jié)果制定的試圖顯示為普通文本處理,這種結(jié)果類型使用很局限,主要用于顯示視圖的碼源。
<result type="plainText">
<param name="location">/welcome.jsp</param>

<param name="charset">GBK</param>
</result>
動態(tài)結(jié)果
login.jsp
--傳入target參數(shù)
LoginAction.java

public class LoginAction extends ActionSupport
{
private String target;
private String tip;

public String execute() throws Exception
{
setTip("歡迎。");
return SUCCESS;
}
}

struts.xml
<action name="login" class="LoginAction">
<result name="success">/${target}.jsp</result>
</action>
需要強(qiáng)調(diào)的是,Action類中必須含有target這個屬性。