日期:2014-05-16  浏览次数:20842 次

菜鸟级问题2 :extjs 下载文件的问题[困扰许久请兄弟们帮着看看]
我使用extjs3和spring做一个功能,其中一项,要求,可以在页面下载word,就是直接弹出一个提示框,其中显示保存打开按钮的
我的对应部分代码如下extjs代码
……
frm.submit({
url : '../templateManage.do?method=runTemplate',
params: {
  operateIds: operateValue,
  tempalteId:combo.getValue()
  },
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(frm, action) {
Ext.Msg.alert('消息', action.result.msg);
}
}
);
下面是部分spring代码
@RequestMapping(params = "method=runTemplate")
public void runTemplate(HttpServletResponse response,HttpServletRequest request)throws Exception
{
  ……
  byte[] b=ParseWordTemplate.parseTemplate(in,map);  
  response.setContentType("application/msword");
  response.setHeader("Content-disposition","attachment;filename=Example.doc");
  response.setContentLength(b.length);
  ServletOutputStream sos = response.getOutputStream();
  sos.write(b, 0, b.length);
  sos.flush();
  sos.close();
   
  //PrintWriter out = response.getWriter();
  //out.print("{success:true,msg:'保存成功'}");
现在有2个问题按照这样的代码运行时,前台总是报
illegal character ext-all.js第七行
但是java代码没有报任何错误

如果我把上面的注释去掉,java和前台都会报错
请高手指点一下……我如何才能在页面中顺利实现下载框的弹出,已经正确的给返回保存成功信息


------解决方案--------------------
应该是后台返回的数据部对。或是不全