哪一种上传组件和struts结合比较好!
为什么最近提的问题总是没有人回答?
郁闷

解决方案 »

  1.   

    struts到底能不能和uploadbean或者其他的上传组件结合?
    给个答案呀!
    真是急人
      

  2.   

    Apache有一个上传文件的组件
    http://jakarta.apache.org/commons/fileupload/using.html
    去年这个时候用过,感觉还不错
      

  3.   

    页面
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:form  action="/uploadImage.do" enctype="multipart/form-data">
    <table border=0 cellspacing=1  cellpadding=5 width=80% align="center">
    <tr><td>
    <html:file property="file1" />&nbsp;&nbsp;<input type="submit" name="submit"></td></tr>
    </table>
    </html:form>
    struts-config:
    <form-beans>
       <form-bean name="UploadImageForm" type="com.zhijiang.emstar.www.form.UploadImageForm"/>
      </form-beans>
      <action-mappings>
    <action
         path="/uploadImage"
         type="com.zhijiang.emstar.www.action.UploadImage"
         scope="request"
         name="UploadImageForm">
         <forward name="Success" path="/web/e/uploadImage.jsp"/>
         <forward name="validateFailure" path="/web/e/uploadImage.jsp"/>
       </action>
      </action-mappings>
    formbean:
    public class UploadImageForm extends ActionForm{
    private FormFile file1 ;
    public UploadImageForm() {
    super();
    resetFields();
    }
    private void resetFields() {
    setFile1(null);
    } public void setFile1(FormFile file1) {
    this.file1 = file1;
    } public FormFile getFile1() {
    return file1;
    }
    }
    action:
    public class UploadImage extends Action { public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception { UploadImageForm puf = (UploadImageForm) form;
    FormFile file = puf.getFile1();//得到页面的文件
    return mapping.findForward("Success");
    }
      

  4.   

    应该可以的,这是我从我的程序里面剪出来的一段,要是有什么问题,[email protected]联系我也可以!