我写了一个页面 用JSP写的 现在就是有个问题,在页面中需要看一个3D文件,我在JS中写了一个方法,判断如果本机上装得有这种播放器的就会打开,没有的则跳到一个可供下载的页面,这个可供下载的页面该如何写?
解决方案 »
- 两套系统,登陆权限如何做?
- webwork与spring集成,如何配置webwork的action是非单例的?
- 谁给个32位linux的MyEclipse8.5GA的下载地址
- 我在后台做一个站内新闻发布,输入标题,输入内容,点击发布如何自动生成对应的html文件呢?
- 把数据下到本地,还是从服务器端实时下到数据进行刷新
- 高手帮忙,文本框输入的中文显示为乱码?为什么
- javabean移植问题?
- 面试jsp问题全接触
- 这个sql怎么写?
- 求教:如何在jsp中根据数据库中的ID值,写出ID值对应的后面的数据
- xstl和xml转换成html中文问题
- 刚工作,遇到的难题!希望哪位好人帮帮我,第一次发贴求救,工作任务25号就要交.谢谢了
这个是我的下载代码!
<logic:notEmpty name="accessories">
<table width="50%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF">
<table width="50%" border="0" align="left" cellspacing="0" id=tabfj name=tabfj>
<tr>
<td width="16%"> </td>
<td ><b>附件</b></td>
</tr> <logic:iterate id="acc" name="accessories">
<tr id="tr">
<td align="center" width="100">文件名称
</td>
<td align="center">
<a href="<%=webmodule %><bean:write name="acc" property="relativePath"/><bean:write name="acc" property="name"/>">
<bean:write name="acc" property="name"/></a>
</td>
</tr>
</logic:iterate>
</table>
</td>
</tr>
</table>
</logic:notEmpty>
将Content-Type设定成浏览器无法直接打开的类型
如果需要,
下班了写个servlet给你
lz在判断出没有特定播放器后,重新定向到 这个servlet的路径,servlet原封不动的从你指定的目录读取
视频文件传给客户就可以了。
import java.io.FileInputStream;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DownLoad extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=XX.rmvb");
ServletOutputStream sos = response.getOutputStream();
byte [] b = new byte [1024];
FileInputStream fis = new FileInputStream("D:\\myweb\\WEB-INF\\XX.rmvb");
int len;
do
{
len = fis.read(b);
sos.write(b, 0, len);
}while(len > -1);
fis.close();
sos.close();
}
}