我写了一个页面 用JSP写的 现在就是有个问题,在页面中需要看一个3D文件,我在JS中写了一个方法,判断如果本机上装得有这种播放器的就会打开,没有的则跳到一个可供下载的页面,这个可供下载的页面该如何写?

解决方案 »

  1.   

    没太搞明白你说的下载是什么意思!
    这个是我的下载代码!
    <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%">&nbsp;</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>
      

  2.   

    可以用servlet实现啊
    将Content-Type设定成浏览器无法直接打开的类型
      

  3.   

    我写了一个页面 用JSP写的 现在就是有个问题,在页面中需要看一个3D文件,我在JS中写了一个方法,判断如果本机上装得有这种播放器的就会打开,没有的则跳到一个可供下载的页面,这个可供下载的页面该如何写?
    如果需要,
    下班了写个servlet给你
    lz在判断出没有特定播放器后,重新定向到  这个servlet的路径,servlet原封不动的从你指定的目录读取
    视频文件传给客户就可以了。
      

  4.   


    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();
      }
    }