如题,在FF下测试是正常的,chrome 也正常,IE7以上版本也正常,惟独IE6不行。
可在 http://www.tuanhaoduo.com 主页左上角上测试(绝非广告贴,还请管理员谅解)。
求解,谢谢了。
@Controller @RequestMapping("/*.do") public class IndexController extends BaseController { // 省略其他无关函数 @RequestMapping public String down4desk(HttpServletRequest request, HttpServletResponse response) { response.setContentType("application/x-msdownload"); String content = ""; try { response.setHeader("Content-Disposition", "attachment;filename=" + new String("团好多.url".getBytes("gbk"), "iso-8859-1")); content = FileUtil.read(Constant.HTMLROOT + "tuanhaoduo.url", true, "UTF-8"); } catch (Exception e) { e.printStackTrace(); } return renderText(request, response, content); } }
FileUtil类中的相关函数:
/** * 读取文件 * * @param filename * @param isSet * 是否需要加上换行 * @param strCode * 编码,如GBK * @return * @throws IOException */ public static String read(String filename, boolean isSet, String strCode) throws IOException { File file = new File(filename); InputStreamReader read = new InputStreamReader( new FileInputStream(file), strCode); BufferedReader reader = new BufferedReader(read); String line = ""; StringBuffer readfile = new StringBuffer(); while ((line = reader.readLine()) != null) { readfile.append(line); if (isSet) readfile.append("\r\n"); } reader.close(); read.close(); return readfile.toString(); }
其中,Constant.HTMLROOT 的值从配置中取得,值为:/home/htmlfile/tuan/
模板语言用到了 apache volicity, 控制器用到了 springMVC。