应该是你提交了两次请求,也许你在js中做了请求的提交而jsp页面控件本身也提交请求了,image button,submit等控件都可以提交请求的,请再查查

解决方案 »

  1.   

    action执行两次,可以肯定的是一定提交了两次请求!!!
      

  2.   

    页面的代码是这样的,直接用form提交的   <s:form action="exportxls" method="post" namespace="/signup" >
        <fieldset class="Normal FloatLeft" style="width: 99%;">
          <legend>导出</legend>
         <dl style="line-height:17pt;">
          <dt>&nbsp;</dt>
    <dt>起始日期</dt>
         <dd>
              <input id="beginDate" name="beginDate" value="" />
              <img style="cursor:hand" id="img_calendar" src="../skin/images/calendar.gif" class="calendar" target="beginDate" showtime="2" />
              </dd>
              <dt>终止日期</dt>
              <dd>
              <input id="endDate" name="endDate" value="" />
              <img style="cursor:hand" id="img_calendar" src="../skin/images/calendar.gif" class="calendar" target="endDate" showtime="2" />
              </dd>
            </dl>
            <dl>
              <dt></dt>
              <dd>
                <input type="submit" class="tijiaoButton" value="导出"/>
              </dd>
            </dl>
          </fieldset>
          </s:form>
      

  3.   

    Action方法 public String exportxls()
        {
            HttpServletRequest request = getRequest();
            String beginDate = request.getParameter("beginDate");
            String endDate = request.getParameter("endDate");
            List<RscoFault> faults=getHibernateUtil().getRscoFaultByResolvDate(beginDate,endDate);  ByteArrayOutputStream out = new ByteArrayOutputStream();            try
                {
    //                os=new FileOutputStream(fault);
                    
                    //第一步,创建一个webbook,对应一个Excel文件
                    HSSFWorkbook wb = new HSSFWorkbook();
                    //第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
                    HSSFSheet sheet = wb.createSheet("表一");
                    //第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
                    HSSFRow row = sheet.createRow((int)0);
                    //第四步,创建单元格,并设置值表头  设置表头居中
                    HSSFCellStyle style = wb.createCellStyle();
                    style.setAlignment(HSSFCellStyle.ALIGN_CENTER); //创建一个居中格式
                    
                    HSSFCell cell = row.createCell((short)0);
                    cell.setCellValue("名称"); cell.setCellStyle(style);
                    cell = row.createCell((short)1);
                    cell.setCellValue("编号"); cell.setCellStyle(style);              。。
                 }
                    wb.write(out);
                    out.flush();
                    setFileName("fault"+beginDate+"--"+endDate);
                    byte[] content = out.toByteArray();   
                    this.excelStream=new ByteArrayInputStream(content);
               }
                catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }  
                finally
                {
                    if(out!=null)
                        try
                        {
                            out.close();
                        }
                        catch (IOException e)
                        {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                }
          
            return SUCCESS;
        }
    struts.xml<action name="exportxls" class="com.rdo.wodflww.action.SignUpAction" 
    method="exportxls">
                <result name="success" type="stream">
                   <param name="contentType">application/vnd.ms-excel</param>
       <param name="inputName">excelStream</param>  
                   <param name="contentDisposition">attachment;filename="${fileName}.xls"</param>  
                   <param name="bufferSize">1024</param>
                </result>  
    </action>
    第一次action执行弹出文件下载  获取文件信息
      exporxls.do(来自localhost)
    的窗口。
    第二次action执行弹出
    另存为的窗口。
    就可以保存了怎么不弹出出一个窗口,显示打开和保存按钮的呢?
      

  4.   

    <param name="bufferSize">1024</param>

    删了试试。
      

  5.   

    不要用form指定提交,自己写提交方法,在提交完成后,重置 this.form.action = "";
      

  6.   

    大家好,你这个问题我最近也碰到了,当时我用的是360浏览器进行的测试(有参数 产品名),点击导出excel后,对应的action也是执行2次,第一次获取的产品名正确,第二次获取的产品名为null,我花了近2天得时间没搞明白,接着我用IE浏览器进行测试,发现了令人兴奋的结果:action执行一次且导出的结果正确,需要说明的是火狐浏览器测试的结果也正确。
      

  7.   

    夏天的时候我也遇见了这个问题,但这不是struts的问题。是你请求了两次或者是调用了两次,一个null和一个有的话多半是前台哪个熊孩子直接copy的别个的源码没改