文件下载
文件下载的方式:
1.超连接下载
2.服务器端通过流下载(服务器端编程)
超连接下载
download1.jsp
<a href='${pageContext.request.contextPath}/upload/a.bmp'>a.bmp</a><br>
<a href='${pageContext.request.contextPath}/upload/a.doc'>a.doc</a><br>
<a href='${pageContext.request.contextPath}/upload/a.txt'>a.txt</a><br>
<a href='${pageContext.request.contextPath}/upload/tk.mp3'>tk.mp3</a><br>
注意:如果文件可以直接被浏览器解析,那么会在浏览器中直接打开,不能被浏览器直接解析,就是下
载操作。
直接打开的要想下载 ,右键另存为。
超连接下载,要求下载 的资源,必须是可以直接被浏览器直接访问的。
客户端访问服务器静态资源文件时,静态资源文件是通过 缺省Servlet返回的,
在tomcat配置文件conf/web.xml 找到 --- org.apache.catalina.servlets.DefaultServlet
Hyperlinks point directly Resources
If the file format browser identification, will directly open the file, is displayed on the browser, if the browser does not recognize the file format, the download window will pop up
For file browser identification format for download via Save As
Client Access server static resource files, static resource files are returned by the default Servlet, found in the tomcat configuration file conf / web.xml --- org.apache.catalina.servlets.DefaultServlet