在xml中跳轉action我想你們都是會的,那麼註解中跳轉其實也很相似,廢話很少說,直接上代碼: apache
@Results({
@Result(name = "toEditFollow", type = "redirect", location = "follow!toEditFollow?baseId=${baseInfo.baseId}&&flag=${flag}")}) 瀏覽器
public String updateOutTime() throws ParseException { spa
//相關操做後
return "toAddFollow";
} xml
這裏面要注意的幾點是: 對象
一、chain是不能夠跳轉其餘action中的方法的,必須使用redirect ci
二、使用redirect要丟失以前的各類參數,須要從新傳遞,傳遞時可使用EL表達式 it
附上xml中返回值的類型,這和註解中實際上是同樣的 io
chain 模板
用來處理Action鏈,被跳轉的action中仍能獲取上個頁面的值,如request信息。 stream
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?