Java 如何使用Spring RESTful Web服务观看视频

Java 如何使用Spring RESTful Web服务观看视频,java,spring,web-services,rest,html5-video,Java,Spring,Web Services,Rest,Html5 Video,我试图从Spring Restful web服务中读取一段视频。 我的web服务是用SpringBoot(tomcat)启动的,我的html是在ApacheHTTP服务器上加载的 我可以观看或下载视频,但我不能在视频中的自定义时间跳转。 当可以从web服务访问视频时,存在此问题(src=”http://localhost:8080/maVideo),但当可以从apache服务器(src=“media/maVideo”)访问视频时,它不存在 这是我的Java代码: @CrossOrigin @Re

我试图从Spring Restful web服务中读取一段视频。 我的web服务是用SpringBoot(tomcat)启动的,我的html是在ApacheHTTP服务器上加载的

我可以观看或下载视频,但我不能在视频中的自定义时间跳转。 当可以从web服务访问视频时,存在此问题(src=”http://localhost:8080/maVideo),但当可以从apache服务器(src=“media/maVideo”)访问视频时,它不存在

这是我的Java代码:

@CrossOrigin
@RequestMapping(value = "/videoSimple/{hash}", method = RequestMethod.GET, headers = "Accept=application/media")
public ResponseEntity<InputStreamResource> videoSimple(final HttpSession session, @PathVariable final String hash) throws IOException {

    final String fileName = "/4_videoToto.mp4";
    final ClassPathResource classPathResource = new ClassPathResource("medias/" + fileName);
    final HttpHeaders headers = createHttpHeaders(fileName, classPathResource);

    final ResponseEntity<InputStreamResource> response = new ResponseEntity<>(new InputStreamResource(classPathResource.getInputStream()), headers, HttpStatus.OK);
    return response;
}
@CrossOrigin
@RequestMapping(value=“/videoSimple/{hash}”,method=RequestMethod.GET,headers=“Accept=application/media”)
public ResponseEntity videoSimple(最终HttpSession会话,@PathVariable最终字符串哈希)引发IOException{
最终字符串fileName=“/4\u videoToto.mp4”;
最终类路径资源类路径资源=新类路径资源(“媒体/”+文件名);
最终HttpHeaders=createHttpHeaders(文件名,classPathResource);
final ResponseEntity response=new ResponseEntity(新的InputStreamResource(classPathResource.getInputStream()),头,HttpStatus.OK);
返回响应;
}
这是我的html代码

<video id="video_telechargeable" width="360" height="250" controls>
        <source src="http://localhost:8080/maVideo" type="video/mp4">
</video>


你知道这个问题吗?

我找到了这个类的解决方案:MultpartFileSender->