首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

struts2 上载文件有关问题

2012-12-16 
struts2 下载文件问题struts2要求在列表中点下载的时候,生成zip文件,里面文件为responseResult.properties

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());
   //如上。。。。   
}

[其他解释]
我早就搞定了,不过还是谢谢!  分全给你了

热点排行