以前做struts2上传一直没有问题。可今天问题出现了。

许多朋友和我一样,取得的文件为null

属性当然也是对的。为什么呢。

是因为struts2上传时要加上传拦截,

如:

<action name="file" class="fileAction">
   <!--Auto Register Action:2010-07-07 14:22:37.281-->
    <!-- 配置fileUpload的拦截器 -->
          <interceptor-ref name="fileUpload">
           <!-- 配置允许上传的文件大小 -->
           <param name="maximumSize">4000000</param>
         </interceptor-ref>
        <interceptor-ref name="defaultStack"></interceptor-ref> 
        <param name="save_path">/fileout</param>
            <result name="fileinfo" type="json">
              file/file.jsp
            </result>
  </action>

配置后可正常上传文件。。

posted on 2010-07-27 09:42  空指针  阅读(2717)  评论(0编辑  收藏  举报