2012-01-04 28 views
1

我在struts-config.xml文件中有下面的action mappings將屬性值從jsp轉發到java

<action path="/getTareWeight" 
    type="com.astrazeneca.usbod.scale.actions.GetTareByBarcodeAction" 
    name ="getTareByBarcodeForm" 
    scope="request" 
    validate="true" 
    input="/jsp/getTareByBarcode.jsp"> 

    <forward name="success" path="/jsp/tareWeightResult.jsp" /> 
    <forward name="failure" path="/jsp/tareWeight.jsp" /> 
    </action> 


    <action path ="/ExportToExcel" 
     type="com.astrazeneca.usbod.scale.actions.ExportTareToExcelAction"> 
    <forward name="success" path="/jsp/tareWeightResult.jsp"/> 
    <forward name="failure" path="/jsp/tareWeight.jsp" /> 
    </action> 

GetTareByBarcodeAction實際設置的屬性如下。

request.getSession().setAttribute("TAREWEIGHT", tareWeightList); 

tareWeightResult.jsp顯示屬性TAREWEIGHT的內容。現在,我把一個按鈕,在tareWeightResult.jsp,這時候點擊屬性TAREWEIGHT的內容應該被髮送到如下一個動作形式,

<html:link forward="exportToExcel">Excel</html:link> 

而在ExportTareToExcelAction.java文件,我有以下的代碼,

List tareWeights = (List) request.getSession().getAttribute("TAREWEIGHT"); 

在這裏,我無法獲得該屬性。它將空值返回到列表tareWeights

請讓我知道什麼是應該做的事在ExportTareToExcelAction.java檢索attibute內容...

回答

1

如果會話屬性爲空,有五種可能性:

  • 你存儲空的屬性
  • 由於您在點擊導出鏈接前未瀏覽應用程序的任何頁面,因此會話已超時
  • 您在點擊導出鏈接之前使會話無效
  • 你沒有使用相同的瀏覽器以獲得皮重,並將它們出口
  • 別的修改會話(例如,過濾器,不同的動作等)