seam 中附件上传

页面部分
<s ileUpload id="uploadProcess"  data="#{sysBulletinHome.bulletinAttchment.content}"
      fileName="#{sysBulletinHome.bulletinAttchment.fileName}"  contentType="#{sysBulletinHome.bulletinAttchment.contentType}"
      fileSize="#{sysBulletinHome.bulletinAttchment.filesize}"/>
      <h:commandButton value="上传文件" action="#{sysBulletinHome.upload}" >
        </h:commandButton>
上面的标签中contentType的属性大家要注意一下,如文件是07版的office文件 文件类型并不是我们想象的.docx或.xlsx ,而是application/vnd.openxmlformats-officedocument.wordprocessingml.document或application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 在 数据库设计的时候要注意contentType的大小
java代码
上传的时候先把上传的文件缓存在set中,在提交保存或更新的时候会持久化到数据库。
public void upload() {
 
  bulletinAttchment.setSysBulletin(getInstance());
  this.getInstance().getSysBulletinAttchments().add(bulletinAttchment);
  bulletinAttchment = new SysBulletinAttchment();
}
Conponents.xml
<!-- 上传组件-->
  <component class="org.jboss.seam.web.MultipartFilter">
    <property name="createTempFiles">true</property>
    <property name="maxRequestSize">10000000</property>
  </component>
web.xml

<filter>  <filter-name>Seam Filter</filter-name>  <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class></filter><filter-mapping>  <filter-name>Seam Filter</filter-name>  <url-pattern>/*</url-pattern></filter-mapping>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值