2012-01-04 78 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

如果会话属性为空,有五种可能性:

  • 你存储空的属性
  • 由于您在点击导出链接前未浏览应用程序的任何页面,因此会话已超时
  • 您在点击导出链接之前使会话无效
  • 你没有使用相同的浏览器以获得皮重,并将它们出口
  • 别的修改会话(例如,过滤器,不同的动作等)