<FORM METHOD="POST"  ACTION="infoJspInserts.jsp"  ENCTYPE="multipart/form-data" name="form">
   <INPUT TYPE="FILE" NAME="FILE1" SIZE="40"><BR>
 <INPUT TYPE="Submit" VALUE="上传" ><%@ page contentType="text/html; charset=utf-8" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
  <head>
    <title>utf-8 upload page</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  </head>
  <body>
        <html:form action="upload-submit.do" enctype="multipart/form-data">Please enter some text, just to demonstrate the handling of text elements as opposed to file elements:
    <br />
    <html:text property="theText" />
    <br />
    <br />Please select the file that you would like to upload:
    <br />
    <!--html:file property="theFile" /-->
<input type =file name="theFile">
    <br />
    <br />If you would rather write this file to another file, please check here: 
    <html:checkbox property="writeFile" />
    <br />
    <br />If you checked the box to write to a file, please specify the file path here:
    <br />
    <html:text property="filePath" />
    <br />
    <br />
    <html:submit /></html:form>
  </body>
</html>
为什么我写的代码浏览文件后上传不了呢?请高手指教

解决方案 »

  1.   

    Form中theFile的类型应为FormFile
    Action中的的操作,struts 自带的example示例程序中有upload的示例
      

  2.   

    http://www.blogcn.com/user41/blog_of_phil/blog/21335216.html
      

  3.   

    jspSmartupload组件 现在没得下载
      

  4.   

    http://blog.csdn.net/jyy7751/services/trackbacks/396495.aspx
      

  5.   

    看 apache struts 自带的commons-fileupload-1.0.jar,
    到 Apache 站点上看, 真简单, 你只要写十几行,就能把 field 和 file 都抽出来.