Step1:在HTML中设置以下代码
<audio autoplay="autoplay" controls="controls" hidden="true">
<source src="/upload/樱花树下的约定+(原版)+-+可泽,夏凌兮.mp3" type="audio/mp3">
<source src="/upload/wecanstop.mp3" type="audio/mp3">
<embed height="50px" width="100px" src="/upload/wecanstop.mp3">
</audio>
Step2:在springmvc配置里“匹配文件路径”(注:文件的路径只需要具体到音乐文件所在的文件夹就行)
//匹配文件的路径
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/upload/**").addResourceLocations("file:c:/Users/.../music/");
}