因为mac电脑识别不出在线 base64图片连接,只识别http形式的在线连接,安卓之别base64链接,不识别http连接,所以得特殊处理,兼容。
//设置下级提交单位名称 Map<String,Object> dataMap = new HashMap<String, Object>(); dataMap.put("newsReadTitle", record.getNewsReadTitle()); dataMap.put("periodical", record.getPeriodical()); dataMap.put("periodicalDate", record.getPeriodicalDate()); dataMap.put("unitCall", record.getUnitCall()); dataMap.put("periodicalTitle", record.getPeriodicalTitle()); dataMap.put("pContent", record.getPeriodicalContent()); response.setContentType("application/vnd.ms-word;charset=UTF-8"); String fileName = record.getNewsReadTitle() +".doc"; String sDownLoadName = new String(fileName.getBytes("GBK"), "ISO-8859-1"); response.setHeader("Content-disposition", "attachment; filename=" + sDownLoadName); Configuration configuration = new Configuration(); configuration.setDefaultEncoding("utf-8"); /** * 以下是两种指定ftl文件所在目录路径的方式,注意这两种方式都是 * 指定ftl文件所在目录的路径,而不是ftl文件的路径 */ configuration.setClassForTemplateLoading(this.getClass(), "/template"); //以utf-8的编码读取ftl文件 Template template = configuration.getTemplate("newspaperreview.ftl", "utf-8"); ServletOutputStream servletout = response.getOutputStream(); Writer out = new BufferedWriter(new OutputStreamWriter(servletout, "utf-8"), 10240); template.process(dataMap, out); servletout.flush(); servletout.close(); out.flush(); out.close();