我有一个带有文件列表的数据表,其中一些是声音文件 . 如果我使用流Firebug说网络错误404.我通过编写文件使其工作(但param autoplay = false不起作用),但它是一个丑陋的解决方法,我可能错过了使流工作的东西 .

萤火虫说:

“NetworkError:404 not found - http://localhost:8080/Projet/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&v=5.3&pfdrid=1G8w72KY96Ob6Ye0QRtzBg%3D%3D&pfdrt=sc&pfdrid_c=true

<p:dataTable var="doc" value="#{besoin.document}" id="besoinTableDocument"
         draggableColumns="true" resizableColumns="true"
         scrollable="true" scrollHeight="150"
         selectionMode="single" rowKey="#{doc.id}">
         <f:facet name="header">
            <p:commandButton value="Upload" icon="ui-icon-extlink" onclick="PF('dlgupload').show();">
               <f:attribute name="filId" value="0" />
            </p:commandButton>
         </f:facet>
         
<p:column sortBy="nom" headerText="Nom"> <h:outputText value="#{doc.nom}" /> </p:column> <p:column> <p:commandButton icon="ui-icon-search" title="Télécharger" ajax="false" actionListener="#{documentBacking.makeFile}"> <f:attribute name="doc" value="#{doc}"/> <p:fileDownload value="#{documentBacking.file}" /> </p:commandButton> <p:commandButton icon="ui-icon-trash" title="Supprimer" ajax="true" actionListener="#{besoinView.deleteDocument}" update="besoinTableDocument"> <p:confirm header="Confirmation" message="Valider la suppression" icon="ui-icon-alert" /> <f:attribute name="doc" value="#{doc}"/> </p:commandButton> </p:column> <p:column> <<p:media value="/resources/sound/#{doc.nom}" player="quicktime" rendered="#{doc.sound}" width="200" height="30" > <f:param name="autoPlay" value="false"/> </p:media> <p:media value="#{doc.stream}" player="quicktime" width="180" height="30" rendered="#{doc.sound}"/> <f:param name="autoPlay" value="false"/> </p:media> </p:column> </p:dataTable>

ManagedBean

@ManagedBean
@RequestScoped
public class Document implements Serializable {
   /**
    *
    */
   private static final long serialVersionUID = 1L;
   private int id;
   private Besoin besoin;
   private String nom;
   private Blob blob;
   private boolean sound;
   private StreamedContent stream;

   public Document(ResultSet rs, Besoin bean) throws SQLException {
      this.id = rs.getInt("DOC_ID");
      this.nom = rs.getString("DOC_NOM");
      this.blob = rs.getBlob("DOC_BLOB");
      this.besoin = bean;
      this.sound = FilenameUtils.getExtension(nom).matches("^(ogg|mp3|mp4)$");
      InputStream in = blob.getBinaryStream();
      String mime = FacesContext.getCurrentInstance().getExternalContext().getMimeType(nom);
      this.stream = (sound?new DefaultStreamedContent(in, mime):null);
   }

   public int getId() {
      return id;
   }

   public void setId(int id) {
      this.id = id;
   }

   public Besoin getBesoin() {
      return besoin;
   }

   public void setBesoin(Besoin besoin) {
      this.besoin = besoin;
   }

   public String getNom() {
      return nom;
   }

   public void setNom(String nom) {
      this.nom = nom;
   }

   public Blob getBlob() {
      return blob;
   }

   public void setBlob(Blob blob) {
      this.blob = blob;
   }

   public boolean isSound() {
      return sound;
   }

   public void setSound(boolean sound) {
      this.sound = sound;
   }

   public StreamedContent getStream() {
      return stream;
   }

   public void setStream(StreamedContent stream) {
      this.stream = stream;
   }

}