关于s:fileupload的问题

在使用s:fileupload时,提取文件总显示为空,长度为零,其他诸如filename,contenttype等也为Null.这个问题怎么办?谁知道什么原因?
我的用的jboss+seam:
web.xml:

<context-param>
<param-name>com.icesoft.faces.uploadDirectory</param-name>
<param-value>upload</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.uploadMaxFileSize</param-name>
<param-value>1001048576</param-value>
</context-param>


<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>com.icesoft.faces.component.inputfile.FileUploadServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>

component.xml:
         <web:multipart-filter create-temp-files="false" 
max-request-size="10485760"
url-pattern="/*"/>


backingbean:

@Stateless
@Name("filebean")
public class FileBean implements FileBeanInterface {

@Logger
private Log log;

@PersistenceContext
private EntityManager em;

private FileData filedata=new FileData();
private String msginfo="";
//@In(value="#{facesContext}")
FacesContext facesContext=FacesContext.getCurrentInstance();
private ExternalContext extCtx=facesContext.getExternalContext();

private List<FileData> filelist=new ArrayList();

private Long attachmentId;

public Long getAttachmentid(){
return attachmentId;
}
public void setAttachmentid(Long attachmentid){
this.attachmentId=attachmentid;
}
public String setFiledata(FileData file){
this.filedata=file;
return null;
}
public FileData getFiledata(){
return this.filedata;
}
public String getMsginfo(){
msginfo=filedata.getContentType();
return msginfo;
}


public String download(Long id){
setAttachmentid(id);
return download();
}
public String download() {
FileData attachment = em.find(FileData.class, attachmentId);
HttpServletResponse response = (HttpServletResponse)extCtx.getResponse();
response.setContentType(attachment.getContentType());
response.addHeader("Content-disposition", "attachment; filename=\"" + attachment.getName() +"\"");
try {
ServletOutputStream os = response.getOutputStream();
os.write(attachment.getData());
os.flush();
os.close();
facesContext.responseComplete();
} catch(Exception e) {
log.error("\nFailure : " + e.toString() + "\n");
}

return null;
}

public String saveFile(){
try{
em.persist(filedata);
filedata=new FileData();
}catch(Exception ex){

}

return null;
}

public String deleteFile(){
FileData to_delete=em.find(FileData.class,attachmentId);
em.remove(to_delete);
em.flush();
getFilelist();
return null;
}

public String deleteFile(Long id){
setAttachmentid(id);
return deleteFile();
}

public List<FileData> getFilelist(){
filelist=em.createQuery("select f from FileData f").getResultList();
return filelist;
}
public void setFilelist(List<FileData> filelist){
this.filelist=filelist;
}



xhtml

<h:form enctype="multipart/form-data" >
<s:fileUpload id="fileupload" accept="text/html"
data="#{filebean.filedata.data}"
contentType="#{filebean.filedata.contentType}"
fileName="#{filebean.filedata.name}"
fileSize="#{filebean.filedata.size}"/>
<br/><br/>
文件名称:<h:outputText value="#{filebean.filedata.name}"/>
<br/><br/>
内容类型:<h:outputText value="#{filebean.filedata.contentType}"/>
<br/><br/>
文件长度:<h:outputText value="#{filebean.filedata.size}"/>
<br/><br/>
<ice:commandButton value="Upload" partialSubmit="true"
action="#{filebean.saveFile}"/>
</h:form>


谁能给看一下怎么回事?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值