我想從我的index.html中調用我的jsp頁面。這是html代碼。如何從我的index.html文件調用jsp頁面?
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<form action="DownloadFile.jsp">
<body>
<div>Click here Download File from Server...</div>
<input type="submit" name="downloadButton" value="Download..." />
</body>
</form>
</html>
JSP PAGE:
<%
String filename = "Sample1.zip";
String filepath = "e:\\temp\\";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(filepath + filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
%>
但是當我按下載按鈕時,它只是顯示了jsp文件的內容,因爲html.it並沒有開始下載文件。什麼是這裏的問題...
而且我上無法下載的.docx和.jpg文件correctly.It說,文件可能已損壞......
請指引我走出這兩個問題...
有沒有一種常見的方式來下載jsp中的所有類型的文件?
至於*「是否有下載所有類型的JSP文件的常用方法?」 *,頭http://stackoverflow.com/q/1812244 – BalusC