无法使用Spring MVC在JSP中播放.mp3文件

时间:2019-04-07 11:13:12

标签: java spring audio

基本上,我正在上传和下载代码 我上传.mp3到tomcat apache,然后移到我们的项目文件夹中 之后,我尝试在JSP页面上播放该歌曲, 但我无法做到这一点。 首先,我认为mp3文件的路径错误。然后我尝试使用HTML,在HTML文件中一切正常,但在JSP中却没有。

注意-音频标签太多,因为链接(音频标签的src)不正确。

JSP身体代码

<body>



<embed src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="true" EnableContextMenu="false" width="700" height="500" autostart="false" loop="false" align="middle" volume="60" ></embed>

<audio controls>
<source src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3" type="audio/wav" >
</audio>



<audio controls>
<source src="/MusicAppForCuples/WebContent/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

<audio controls>
<source src="MusicAppForCuples/WebContent/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>


<audio controls>
<source src="/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

<audio controls>
<source src="/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

    <audio controls>
      <source src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3"
       type="audio/mpeg">
    </audio>

        <audio controls>
      <source src="E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3"
       type="audio/mpeg">
    </audio>

    <br>

    <audio controls>
      <source src=" <% out.print((rootPath));%>\text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

        <audio controls>
      <source src=" <% out.print(rootPath);%>text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>


   <audio controls>
     <source src="/text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

    <embed src="E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3">


</body>

HTML身体代码


<embed src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="true" EnableContextMenu="false" width="700" height="500" autostart="false" loop="false" align="middle" volume="60" ></embed>

<audio controls>
<source src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3" type="audio/wav" >
</audio>



<audio controls>
<source src="/MusicAppForCuples/WebContent/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

<audio controls>
<source src="MusicAppForCuples/WebContent/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>


<audio controls>
<source src="/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

<audio controls>
<source src="/musicAdmin/somesh.mp3" type="audio/mpeg" >
</audio>

    <audio controls>
      <source src="file:///E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3"
       type="audio/mpeg">
    </audio>

        <audio controls>
      <source src="E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3"
       type="audio/mpeg">
    </audio>

    <br>

    <audio controls>
      <source src=" <% out.print((rootPath));%>\text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

        <audio controls>
      <source src=" <% out.print(rootPath);%>text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>


   <audio controls>
     <source src="/text_fileuploadzeAmhjygg6.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

    <embed src="E:/Code_IDE/apache-tomcat-9.0.14/apache-tomcat-9.0.14/somesh/text_fileuploadzeAmhjygg6.mp3">


</body>

```[JSP image -- not working][1]


[HTML page -- with same coding -- 4 tags are working (other tags are not wrking because of link issue)][2]


  [1]: https://i.stack.imgur.com/5zgbe.png
  [2]: https://i.stack.imgur.com/Vj1E6.png



NOTE -- If you want other details like code and all please let me know. 

0 个答案:

没有答案