Home > Net >  How to serve audio files in sping boot
How to serve audio files in sping boot

Time:11-16

I have audio tag in html, I need to know the src attribute, where should I put the audio folder to be able to reference it as src="audio/audio_name" ?

I tried to put it in resources folder, but when put src="http://localhost:9191/resources/audios/audio_name" it returned 404 not found

CodePudding user response:

You'd need to put your audio file into of the following directories:

  • /META-INF/resources/
  • /resources/
  • /static/
  • /public/

You can then reference a file /static/audio/file.mp3 from HTML with /audio/file.mp3.

See Serving Static Web Content with Spring Boot.

  • Related