在這個頁面裏點超鏈就會直接生成word:
<html>
<head>
<title>word</title>
</head>
<body>
<p><a href="new.jsp">word</a></p>
</body>
</html>
生成word的代碼:
<%@ page contentType="application/msword;charset=gb2312" %>
<%@ page import="*****%>
<%
response.setHeader("Content-disposition","inline; filename=test1.doc"); //線上瀏覽方式
response.setHeader("Content-disposition","attachment; filename=test1.doc");//下載方式
%>
<html>
......全是你需要的代碼..你要顯示的東東和一般的JSP頁面的寫法沒有任何不同.....
</html>
<%
String filename = "東東--";
response.setHeader("Content-Disposition", "attachment; filename="+ java.net.URLEncoder.encode(filename, "UTF-8") +".doc");%>用utf-8可以實現中文名字的書寫