@Results({
@Result(name = "toEditFollow", type = "redirect", location = "follow!toEditFollow?baseId=${baseInfo.baseId}&&flag=${flag}")})
public String updateOutTime() throws ParseException {
//相關操作後
return "toAddFollow";
}
這裏面要注意的幾點是:
1、chain是不可以跳轉其他action中的方法的,必須使用redirect
2、使用redirect要丟失之前的各種參數,需要重新傳遞,傳遞時可以使用EL表達式
附上xml中返回值的類型,這和註解中其實是一樣的
chain
用來處理Action鏈,被跳轉的action中仍能獲取上個頁面的值,如request信息。
com.opensymphony.xwork2.ActionChainResult
dispatcher
用來轉向頁面,通常處理JSP
org.apache.struts2.dispatcher.ServletDispatcherResult
redirect
重定向到一個URL?,被跳轉的頁面中丟失傳遞的信息,如request
org.apache.struts2.dispatcher.ServletRedirectResult
redirectAction
重定向到一個Action?,跳轉的頁面中丟失傳遞的信息,如request
org.apache.struts2.dispatcher.ServletActionRedirectResult
redirect-action
重定向到一個Action?,跳轉的頁面中丟失傳遞的信息,如request
org.apache.struts2.dispatcher.ServletActionRedirectResult?
//以下不常用
freemaker
處理FreeMarker模板
org.apache.struts2.views.freemarker.FreemarkerResult
httpheader
控制特殊HTTP行爲的結果類型
org.apache.struts2.dispatcher.HttpHeaderResult
stream?
向瀏覽器發送InputSream對象,通常用來處理文件下載,還可用於返回AJAX數據
org.apache.struts2.dispatcher.StreamResult
velocity
處理Velocity模板
org.apache.struts2.dispatcher.VelocityResult
xslt
處理XML/XLST模板
org.apache.struts2.views.xslt.XSLTResult
plainText
顯示原始文件內容,例如文件源代碼
org.apache.struts2.dispatcher.PlainTextResult
plaintext
顯示原始文件內容,例如文件源代碼
org.apache.struts2.dispatcher.PlainTextResult?