日期:2014-05-20  浏览次数:20589 次

struts2 下载文件问题
struts2   要求在列表中点下载的时候,生成zip文件,里面文件为responseResult.properties,内容为ip=192.168.72.209
port=8080
createTime=2012-08-16 13:30:50

帮帮忙啊    着急用
------最佳解决方案--------------------
-_-!  话说有分拿

ZipOutputStream bos=null;
try{
ZipEntry entry=new ZipEntry("some.properties");
bos=new ZipOutputStream(new FileOutputStream("d:/some.zip"));
bos.putNextEntry(entry);
bos.write("id=192.168.1.1\r\n".getBytes());
bos.write("port=8080\r\n".getBytes());
bos.write("createTime=2012-08-16 13:30:50\r\n".getBytes());
bos.flush();
}catch(IOException e){
  //xx00
}finally{
  bos.close();
}

------其他解决方案--------------------
额,需不需要补充完整啊?

public String execute(){
   ZipOutputStream bos=null;
   HttpServletResponse resp=ServletActionContext.getResponse();
   bos=new ZipOutputStream(resp.getOutputStream());
   //如上。。。。   
}

------其他解决方案--------------------
我早就搞定了,不过还是谢谢!  分全给你了