<input type="file" name="theFile"/>  
改成      <input type="file" name="file"/>  或者
private FormFile file; 
改成
private FormFile theFile; 

解决方案 »

  1.   

    改了,但出现以下异常:java.lang.IllegalArgumentException: Cannot invoke com.test.form.TestForm.setTheFile - argument type mismatch
    org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778)
    org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
    org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
    org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
    org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
    org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
    ........百度了一下说是表单file与ActionForm里的FomrFile不一致...
      

  2.   

    up~
    我和LZ碰到了相同的问题~
    哪位高手解答一下~~~
      

  3.   

    当然了,你一定要把<form>里的原素改成和formbean里面的属性一样,不原的话是取不到值的!!!!
    一定要改成一样!
      

  4.   

    <input type="file" name="theFile"/> 改成<html:file property="file"/><html:form action="test.do" name="testForm" enctype="multipart/form-data">      
    <center> 
        <font style="font-size:12px;color:red">请选择需要上传的照片 : </font> 
        <html:file property="file"/>
        <html:submit property="submit"/>
    </center> 
    </html:form>
      

  5.   

    <input type="file" name="theFile"/>要改成
    <input type="file" name="file"/>别倒过来改
      

  6.   

    private FormFile file; <input type="file" name="theFile"/> 这当然取不到了。7楼给出答案了
      

  7.   

    在form后加上  enctype="multipart/form-data"
      

  8.   

    你那个标签用的不对,你必须用struts自己的html<html:text>标签。才能把控件里的值给你封装成对象,如果还用原来的<html>标签,在action里当然取不到