读书人

struts2 上载文件有关问题

发布时间: 2012-12-16 12:02:32 作者: rapoo

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

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

读书人网 >Java相关

热点推荐