当前位置: 代码迷 >> Web前端 >> 附件下传
  详细解决方案

附件下传

热度:184   发布时间:2012-08-30 09:55:54.0
附件上传

1.对应的配置文件

<property name="fileIds" type="string">
???<meta attribute="field-description">附件</meta>
???<column name="annex" />
??</property>

2,对应的数据库修改

alter table S_ART_PRODUCT add ANNEX varchar(225);

?

3.save

bean.setFileIds(bo.addAtt(thisForm.getFiles()));

?

4.update

//加入保存附件
???String ylIds="";
???try {
????ylIds = bo.updateAtt(thisForm.getFiles(), bean
??????.getFileIds(), thisForm.getRemoveFiles());
???} catch (AttachementException e) {
????generalError(request, e);
????return mapping.findForward(ADD);
???} catch (Exception e) {
????generalError(request, e);
????return mapping.findForward(FAIL);
???}
???bean.setFileIds(ylIds);

?

?

5.add页面

enctype="multipart/form-data"


<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<script Language="JavaScript" src="../../script/multiAtt.js"/></script>


var fileNum=1;
?
?
<html:hidden property="removeFiles"/>


<FIELDSET>
??<LEGEND>【附件信息】</LEGEND>
??<table id="table" cellspacing="0" cellpadding="0" align="center">
???<tr>
????<td class="list" >电子版附件:</td>
????<TD class="list" colspan="3" >
?????<logic:notEmpty name="businessPracticeForm" property="bean.fileIds">
??????<logic:iterate id="id" indexId="index" name="businessPracticeForm" property="bean.fileIdss" type="java.lang.String">
???????<div id="f_<%=index%>" name="${id}">&nbsp;<a href="download.download?id=<%=id.split("\\|")[0]%>" target="_blank"><font color="red"><%=id.split("\\|")[1] %></font></a><a onclick="delF(f_<%=index %>)">删除</a></div>
??????</logic:iterate>
?????</logic:notEmpty>
?????<table border="0"><tbody id="fileTable" border="0">
?????? <tr><td class="td_noborder">
?????? <nested:iterate id="uploadFile" property="files" name="businessPracticeForm" indexId="index">
??????? <nested:nest property="uploadFile">
???????<nested:file property="file" name="uploadFile" indexed="true" onkeydown="return false;" onchange="checkFile(this)"/>
??????? </nested:nest>
?????? </nested:iterate>
?????????? </td></tr>
?????</tbody></table>
?????&nbsp;<a href="javaScript:addDynaFileItem(this,fileNum);addFileNum();" class="list_link">添加附件</a>
?????</td>
???</tr>
??</table>
?</FIELDSET>
?
?

6.view页面
?<FIELDSET>
??<LEGEND>【附件信息】</LEGEND>
??<table id="table" cellspacing="0" cellpadding="0" align="center">
???<tr>
????<td class="list" >电子版附件:</td>
????<TD class="list" colspan="3" >
?????<logic:notEmpty name="businessPracticeForm" property="bean.fileIds">
??????<logic:iterate id="id" indexId="index" name="businessPracticeForm" property="bean.fileIdss" type="java.lang.String">
???????<div id="f_<%=index%>" name="${id}"><a href="download.download?id=<%=id.split("\\|")[0]%>" target="_blank"><font color="red"><%=id.split("\\|")[1] %></font></a></div>
??????</logic:iterate>
?????</logic:notEmpty>
?????<table border="0"><tbody id="fileTable" border="0">
?????? <tr><td class="td_noborder">
?????? <nested:iterate id="uploadFile" property="files" name="businessPracticeForm" indexId="index">
??????? <nested:nest property="uploadFile">
???????<nested:file property="file" name="uploadFile" indexed="true" onkeydown="return false;" onchange="checkFile(this)"/>
??????? </nested:nest>
?????? </nested:iterate>
?????????? </td></tr>
?????</tbody></table>
?????</td>
???</tr>
??</table>
?</FIELDSET>

?

?

?

?

?

?

?

?

?

?

?

?

  相关解决方案