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

<param name="charset">GBK</param>
</result>
動態結果
login.jsp
--傳入target參數
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>
需要強調的是,Action類中必須含有target這個屬性。