我在action中直接用this.getResponse().sendRedirect(a.xls); 打开一个excel文件会弹出另存为的小窗口,当我保存完毕再去点击页面的其它连接时,又回到了网站的登录页面。我是先调用ftp的下载方法下载到工程的文件夹下,然后从文件夹取出的。
这是ftp的下载方法
public void download(String fileName,String filepath) throws IOException{
boolean flag = connectServer("ftp地址", "用户名", "密码");
// connectServer(ip, userName, password,savePath);
//String fileName = request.getParameter("filename");
TelnetInputStream ftpIn=null;
FileOutputStream ftpOut=null;
try{
ftpIn = ftpClient.get(fileName); //fileName为FTP服务器上要下载的文件名
byte[] buf = new byte[204800];
int bufsize = 0;
ftpOut = new FileOutputStream(filepath); //存放在本地硬盘的物理位置
while ((bufsize = ftpIn.read(buf, 0, buf.length)) != -1) {
ftpOut.write(buf, 0, bufsize); }
}catch(Exception e){
e.printStackTrace();
}finally{
if (ftpIn != null) {
ftpIn.close();
}
if (ftpOut != null) {
ftpOut.close();
}
if (ftpClient != null) {
ftpClient.closeServer();
}
}
}这怎么解决啊,在线等!!!!!急啊。 或者有其他的另存为方法 吗,给位大侠 求助
这是ftp的下载方法
public void download(String fileName,String filepath) throws IOException{
boolean flag = connectServer("ftp地址", "用户名", "密码");
// connectServer(ip, userName, password,savePath);
//String fileName = request.getParameter("filename");
TelnetInputStream ftpIn=null;
FileOutputStream ftpOut=null;
try{
ftpIn = ftpClient.get(fileName); //fileName为FTP服务器上要下载的文件名
byte[] buf = new byte[204800];
int bufsize = 0;
ftpOut = new FileOutputStream(filepath); //存放在本地硬盘的物理位置
while ((bufsize = ftpIn.read(buf, 0, buf.length)) != -1) {
ftpOut.write(buf, 0, bufsize); }
}catch(Exception e){
e.printStackTrace();
}finally{
if (ftpIn != null) {
ftpIn.close();
}
if (ftpOut != null) {
ftpOut.close();
}
if (ftpClient != null) {
ftpClient.closeServer();
}
}
}这怎么解决啊,在线等!!!!!急啊。 或者有其他的另存为方法 吗,给位大侠 求助
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货