服务器端做了下面的事情:
HttpServletResponse response = ((AppWorkspace)this.getWorkspace()).getResponse();
response.reset();
response.setContentType("application/vnd.ms-excel;charset=" + ((AppWorkspace)this.getWorkspace()).getEncode());
ServletOutputStream out = response.getOutputStream();
FileInputStream fis = new FileInputStream("/data/test/test.xls");
byte[] buff = new byte[1024];
int bytesRead;
while((bytesRead = fis.read(buff,0,buff.length)) != -1)
{
out.write(buff, 0, bytesRead);
}
HttpServletResponse response = ((AppWorkspace)this.getWorkspace()).getResponse();
response.reset();
response.setContentType("application/vnd.ms-excel;charset=" + ((AppWorkspace)this.getWorkspace()).getEncode());
ServletOutputStream out = response.getOutputStream();
FileInputStream fis = new FileInputStream("/data/test/test.xls");
byte[] buff = new byte[1024];
int bytesRead;
while((bytesRead = fis.read(buff,0,buff.length)) != -1)
{
out.write(buff, 0, bytesRead);
}
在<a href="" target="_blank"(加上的)></a>
setContentType: application/vnd.ms-excel;charset
不是text/html.在原来提交的页面上只是一个提交请求的链接,不是简单的加个<a></a>
试试在out理输出javascript脚本