关于Spreadsheet的问题,找不到文件?
页面中: window.onload=function(){
var spreadSheet = document.getElementById('mySpreadsheet');
var path = "test.xml";
try{
spreadSheet.XMLURL="query.do?cs=info&path="+path;
spreadSheet.refresh();
}catch(ex){
alert('文件不存在!');
}
}
<object id="mySpreadsheet"classid="CLSID:0002E559-0000-0000-C000-000000000046"
style="width:100%;height:400">
</object>
action中:
public ActionForward info(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
OutputStream os = null;
InputStream in = null;
String path=request.getParameter("path");
path=request.getSession().getServletContext().getRealPath("/")+path;
File file = new File(path);
if(!file.exists()){
System.out.println("文件不存在!");
}
try{
response.setContentType("application/unknown");
response.setHeader("Content-Disposition", "attachment; filename=test.xml");
os=response.getOutputStream();
in = new FileInputStream(file);
byte bytes[] = new byte[1024];
for(int len = 0; (len = in.read(bytes)) != -1;)
os.write(bytes, 0, len);
}catch(Exception e){
e.printStackTrace();
}finally{
os.flush();
if(null != in)
in.close();
if(null != os)
os.close();
}
return null;
}
为什么会找不到文件?