struts上传的问题!~
大家快帮帮忙呀!~
我要用struts的上传组件,可是怎样都不行!找找错@!很着急@!
这是我写的部分代码!~
JSP界面
<form name="equipmentForm" action="equipment.do" method="post" ENCTYPE="multipart/form-data">
<table width="1262" height="445">
<tr><td>设备名称:</td>
<td><input type="text" name="mname"></td></tr>
<tr><td>设备照片:</td><td>
<input type="file" name="mphotp" size="20" ></td></tr>
<tr><td align="center" colspan="2">
<input type = "submit" value="提交">
<input type = "reset" value="重置">
</td></tr>
</table>
</form>
FormBean的代码:(EquipmentForm)
public class EquipmentFormForm extends ActionForm {
private String mname;
private FormFile mphoto;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
return null;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
}
public String getMname() {
return mname;
}
public void setMname(String mname) {
this.mname = mname;
}
public FormFile getMphoto() {
return mphoto;
}
public void setMphoto(FormFile mphoto) {
this.mphoto = mphoto;
}
Action代码
EquipmentForm equipmentForm = (EquipmentForm) form;
System.out.println(equipmentForm.getMname().toString());
FormFile file = equipmentForm.getMphotp();
System.out.println(file.getFileName().toString());
return mapping.findForward("success");
但是他只有第一个System.out.println(equipmentForm.getMname().toString());可以输出,在得到file后file还是空!~
到底怎么回事呀?急死了!~高手指点呀!~初学struts!~