jsp下载服务器文件
2018-03-16 13:44
204 查看
1.java后端:保存待下载文件test.txt到realPath下面,其中:
String realPath = request.getSession().getServletContext().getRealPath("/");
2.jsp端Java脚本:取项目访问路径basePath ,其中
<%
String contextPath = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+ request.getServerPort()+contextPath+"/";
%>
3.html标签中定义<input id="outputpath" type="hidden" value="<%=basePath %>"/>
4.js端:访问待下载资源window.location.href=document.getElementById("outputpath").value+"/test.txt";
String realPath = request.getSession().getServletContext().getRealPath("/");
2.jsp端Java脚本:取项目访问路径basePath ,其中
<%
String contextPath = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+ request.getServerPort()+contextPath+"/";
%>
3.html标签中定义<input id="outputpath" type="hidden" value="<%=basePath %>"/>
4.js端:访问待下载资源window.location.href=document.getElementById("outputpath").value+"/test.txt";
相关文章推荐
- JSP下载服务器文件的方法
- 【转载】使用jsp实现文件上传到服务器或者从服务器上下载文件到本地计算机完整说明版
- JSP下载服务器文件的方法
- JAVA中的FtpClient与FTPClient,并实现jsp页面下载ftp服务器上的文件
- 【转载】使用jsp实现文件上传到服务器或者从服务器上下载文件到本地计算机完整说明版
- jsp实现从服务器下载xls文件到客户端的方法
- 下载服务器上的文件的jsp
- JSP下载服务器文件
- jsp+servlet实现大型文件下载(tomcat服务器),将自己今天做的和大家一起分享
- JSP实现远程文件下载保存到服务器指定目录中的方法
- java+jsp代码实现从FTP服务器上传下载文件
- jsp页面点击下载文件 java方式(服务器上带路径文件 以文件流输出)
- jsp从服务器下载xls文件到客户端
- jsp实现从服务器下载xls文件到客户端的方法
- Jsp 下载远程文件至服务器
- JSP实现远程文件下载保存到服务器指定目录中的方法
- jsp从服务器下载xls文件到客户端
- JSP实现从不同服务器上下载文件的方法
- JSP实现从不同服务器上下载文件的方法
- 用压缩流jsp实现从Tomcat服务器下载多个文件