用JSP做一个简单的下载页面【求教】
java吧
全部回复
仅看楼主
level 9
丶渲目 楼主
我希望用servlet + Tomcat 7.0做一个下载页面,一个DOC文件就行
2013年04月08日 03点04分 1
level 15
然后哪?
2013年04月08日 03点04分 2
什么然后?然后同学上网可以下载我的指定的文档啊
2013年04月08日 03点04分
回复 丶渲目 :我开Tomcat 让别人下载
2013年04月08日 03点04分
level 9
丶渲目 楼主
我有上网查,我发现千篇一律。不知道都在哪找的,但源头竟然是错的,无语
2013年04月08日 03点04分 3
level 9
使用stuts2有common-upload组件可以使用.
2013年04月08日 03点04分 5
我菜鸟,你说的东西我还不知道,怎么办
2013年04月08日 03点04分
连servlet都没提到,struts应该还不会吧
2013年04月08日 03点04分
回复 老子叫孽障 :不会呢
2013年04月08日 03点04分
不会的话 只能用 smartupload了 你百度mldn 李兴华有个视频 介绍smartupload的使用的 javaWeb视频 你仔细找找
2013年04月08日 07点04分
level 9
丶渲目 楼主
我在想我就开个tomcat,同学可以下载我的东西吗?老师说可以我都不信
2013年04月08日 03点04分 6
level 12
百度搜索,smartupload
2013年04月08日 03点04分 7
oo
2013年04月08日 03点04分
level 10
(够拽)
好腻害的样子。
2013年04月08日 08点04分 10
level 10
<%@page contentType="text/html; charset=UTF-8" language="java" import="com.jspsmart.upload.*" import="com.ecore.basic.util.StringUtil" import="java.text.*" import="javax.servlet.*,javax.servlet.http.*"%>
<%
try
{
String file=StringUtil.decodeEscapeX(request.getParameter("file"));
System.out.println(file);
ServletContext context=session.getServletContext();
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(pageContext);
mySmartUpload.setContentDisposition(null);
mySmartUpload.downloadFile(file);
}
catch (Exception e)
{ e.printStackTrace();
response.getWriter().write("<html><head><script type='text/javascript'>alert('未找到相应的文件!');window.close();</script></head></html>");
}
finally
{//一定要清除out
out.clear();
out = pageContext.pushBody();
}
%>
2013年04月08日 08点04分 11
file指的是文件的路径
2013年04月08日 08点04分
回复 qqq2221991 :感谢大神,
2013年04月11日 03点04分
level 7
只要是在web.xml里没有指定打开方式的后缀名,这些后缀名的文件放到链接上,点击打开的话,默认都是下载。
2013年04月08日 08点04分 12
level 8
[抖胸] a href 有什么不安全的,话说你这个东西主要问题是得提供一个公网可以访问的IP啦。
2013年04月09日 02点04分 13
level 10
smartupload可以做到
2013年04月11日 03点04分 14
1