千万要注意不能使用Ajax与后台交互,要用window.location.href
参考文档:http://www.myexception.cn/powerdesigner/916193.html
造成这个问题的原因,是通过Ajax下载文件的这种方式本来就是禁止的。出于安全因素的考虑,javascript是不能够保存文件到本地的,所以Ajax考虑到这点,只是接受xml,ajax,json格式的返回值,二进制的返回格式就会抛出异常,浏览器也不会弹出下载提示框。
所以要用window.location.href=url的方式
【20190525】出现url到controller层时,requestmapping无法接收get方式提交url
所以在写controller的方法时,采用 method=requestMethod.GET
@RequestMapping("page") //@RequestMapping(value = "page", method = RequestMethod.GET) 写法二 //@RequestMapping(value = "page", method = RequestMethod.POST) 写法三 public ModelAndView page(String test) { logger.info(">>>>>>" + test); ModelAndView mav = new ModelAndView("appeal/roleManage"); return mav; }
第一种写法没指定method,前端提交时可使用get或者post,第二种只能使用get,第三种只能使用post