1. 程式人生 > >網頁中呼叫word實現的列印

網頁中呼叫word實現的列印

網頁中呼叫word實現列印功能時,可以用word另存為指定xml或網頁形式,然後再通過java的response輸出流寫。主要是contenttype和header如何寫。

1。word另存為htm(比如為C:/test.htm)

response.setContentType("application/msword; charset=GB2312");
response.setHeader("Content-Disposition", "filename=test.htm".getBytes(), "ISO8859-1"));
response.getWriter().write(XXX);  //寫對應InputStream

2。word另存為xml(比如為C:/test.htm)

response.setContentType("application/msword; charset=UTF-8");
response.setHeader("Content-Disposition", "filename=test.htm".getBytes(), "ISO8859-1"));
response.getWriter().write(XXX);  //寫對應InputStream