视频文件的位置在哪里

时间:2019-03-19 17:56:13

标签: java eclipse file

我正在使用Java的eclipse EE。我在WebContent下创建了一个名为video的新文件夹,该文件夹为Cat Boarding.mp4

我只是在玩耍以尝试学习servlet,并具有以下代码:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    PrintWriter out = response.getWriter();
    out.println("<html>");

    out.println("<head>");
       out.println("<title>HW3</title>");
    out.println("</head>");

    out.println("<body>");
       out.println("<b style='color:green;font-size:200%;'>Hello World </b>");

       out.println("<video width='400' controls>");
          out.println("<source src='/Hello World/WebContent/videos/Cat Boarding.mp4' type='video/mp4'>");         
          out.println("Your browser does not support HTML5 video.");
       out.println("</video>");

    out.println("</body>");

    out.println("</html>");
} 

当我尝试运行它时,它说无效的来源

在本地运行时,我使用:http://localhost:8080/HW/hw

按照我尝试的建议

out.println("<source src='/Hello%20World/WebContent/videos/Cat%20Boarding.mp4' type='video/mp4'>");

但是那也不起作用

1 个答案:

答案 0 :(得分:0)

正确的路径是:

<source src='videos/Cat Boarding.mp4' type='video/mp4'>