---
title: "[原]Fileupload和Struts1.2共用注意事项"
author: "独家冠名"
date: "2008-03-17T09:20:41Z"
tags: ["Apache", "JSP", "Servlet", "Struts"]
slug: "fileupload-struts1-2"
draft: false
lastmod: "2008-03-17T09:20:41Z"
id: 172829
url: "https://singlewolf.iteye.com/blog/172829"
---

闲来无事,开始写了个Servlet类来上传,测试成功
但把Servlet类的代码搬到Struts中问题来了
除了Servlet的doGet(),doPost()方法与Struts中的execute()方法外,其它代码完全一样,因为是COPY过去的
只要一上传,ServletFileUpload类的parseRequest方法都是null,郁闷了,差不多花了一个小时时间也没搞定,结果Baidu发现

1.最好不要在jsp页面中使用struts得标签，使用后，通过正常方式无法接收到相关参数。

2.如果使用action，不要使Action继承其他得Action，仅仅继承org.apache.struts.action.Action
<span style="color:red">经亲测Action继承org.apache.struts.actions.DispatchAction类可以上传</span>

3.在配置文件中，不要给action配置actionForm