ActionForward 回話不能儲存

2021-06-18 08:48:07 字數 824 閱讀 1449

actionforward類提供了下面五種構造器:

public actionforward()  

public actionforward(string path) 常用  

public actionforward(string path, boolean redirect)  

public actionforward(string name, string path, boolean redirect)  

public actionforward(string name, string path, boolean redirect, boolean contextrelative)  

顯示中經常用得到2和3,一直分不清,有什麼區別。今天碰到乙個問題:

request.setattribute("type", type);

return new actionforward(url,

true

) ;但是頁面中一直得不到type的值。

後來發現使用return new actionforward(url,

false

) ;就可以了

在actionforward中有乙個重要的屬性 redirect,當redirect=false時,將儲存儲存在http請求和請求上下文中的所有內容,僅在同乙個應用中可用。

當 redirect=true時,web客戶端進行一次新的http請求,請求的資源可以在同乙個應用中,也可以不在,原來的請求引數不再儲存,原來的請求 上下文也被清除,新的http請求僅包含actionforward的path屬性裡所包含的引數。如果在同乙個應用中,使用者會話的上下文會被維護。

ActionForward相關問題

一 靜態的actionforward不能更改屬性 struts config.xml檔案在伺服器啟動的時候就被載入進去,其值不能動態修改。以上在配置檔案中已經配置,現在在action中 forward.setredirect true return forward 由於配置已經在配置檔案中生效,不能...

回話跟蹤技術

會話跟蹤技術概述 為什麼需要會話跟蹤 使用者的活動發生在多個請求和響應之中,web伺服器必須採用一種機制來唯一標識乙個使用者,同時記錄該使用者狀態,這就是web應用程式的典型需求。為了在web應用程式中能夠唯一標識使用者,必須使用會話跟蹤技術。什麼是會話跟蹤 web應用中的會話是乙個客戶端瀏覽器與w...

php回話控制 cookie

class customcookie private function setoptions array option 單例模式 param array option cookie相關選項 result object 物件例項 public static function getinstance a...