私はTomcatサーバー上でfileUploadコンポーネントを使用していますが、正しく動作します。私はweblogicサーバー上で私のアプリケーションを試したとき、ファイルのアップロードコンポーネントが動作していませんでした。Primefaces weblogicを使用したファイルアップロード
私は "アップロード" をクリックした@ManagedBean(name = "fileUploadBean")
@RequestScoped
public class fileUpload {
FileUploadEvent e;
private static final long serialVersionUID = 1L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String uploadPhoto() throws IOException {
System.out.println("resim kaydetme metoduna girildi");
UploadedFile uploadedPhoto = e.getFile();
String filePath = "c:/temp/kk";
byte[] bytes = null;
if (null != uploadedPhoto) {
bytes = uploadedPhoto.getContents();
String filename = FilenameUtils.getName(uploadedPhoto.getFileName());
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(filePath + filename)));
stream.write(bytes);
stream.close();
}
System.out.println("resim kaydettim cikiyorum");
FacesContext.getCurrentInstance().addMessage("messages", new FacesMessage(FacesMessage.SEVERITY_INFO, "(File Name " + uploadedPhoto.getFileName() + " with size " + uploadedPhoto.getSize() + ") Basarili bir sekilde kaydedildi", ""));
return null;
}
}
、私の画像が保存されませんでした。
<h:form id="fileUpoad" prependId="false" enctype="multipart/form-data">
<!-- File Upload with mode="advanced". multiple files can be uploaded. upload button -->
<h:outputLabel for="fileIdPhoto" value="Hasar fotografini yukleyiniz:"/>
<p:fileUpload id="fileIdPhoto" fileUploadListener="#{fileUploadBean.uploadPhoto}" mode="advanced"
dragDropSupport="false"
multiple="true" update="messages" sizeLimit="10000000" fileLimit="3"
allowTypes="/(\.|\/)(gif|jpe?g|zip)$/"/>
<p:messages id="messages" autoUpdate="true" closable="true"/>
</h:form>
は、ここに私のfileUpload
Beanです。ここに私のweblogicサーバのエラーがあります:
Oct 31, 2016 7:54:49 AM com.sun.faces.context.ExternalContextImpl getMimeType WARNING: JSF1091: No mime type could be found for file /denemexhtml.xhtml. To resolve this, add a mime-type mapping to the applications web.xml. Oct 31, 2016 7:54:49 AM com.sun.faces.context.ExternalContextImpl getMimeType WARNING: JSF1091: No mime type could be found for file /denemexhtml.xhtml. To resolve this, add a mime-type mapping to the applications web.xml.
あなたのFileUploadBeanのコードを表示するだけでなく、あなたが持っているエラー/例外の説明を入れてください。 – DimaSan
そして、 "働いていなかった"というのはあいまいです。もっと詳しく調べてください – Kukeltje
この記事を読むhttp://stackoverflow.com/questions/39486157/get-uploaded-file-path-in-primefaces/39487964#39487964と同じ手順を実行します –