首先需要建一个WebMvcConfigurer,如下
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/v/**").addResourceLocations("file:C:/Users/Q/Video/");
}
}
Linux系统同样适用,更改路径表达方式即可
然后是html
<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>Test</title>
<video width="1024" height="640" controls>
<source src="v/TestVedio.mp4" type="video/mp4">
</video>
</head>
<body>
</body>
</html>
然后就可以在网页上看本地视频了。