读书人

struts2 下传文件取不到文件名称

发布时间: 2012-10-15 09:45:25 作者: rapoo

struts2 上传文件取不到文件名称
在用struts2上传文件时,总是取不到文件名.
<input type="file" name="uploadSummary />
在action类定义文件的三个属性
private File uploadSummary;
private String uploadFileName;
private String uploadContentType;
private String savePath; //在xml文件中已指定
在上传时,总是取不到文件名,文件名null,开始以为是拦截器的问题,使用struts2自带的拦截器,还是取不到。后来上网查资料,问题总于解决了,原来时file 的名称只能是upload
即<input type="file" name="upload />,这样写问题就解决了.那么你的文件名称就应该写成
private String uploadSummaryFileName这样才对 2 楼 347650865 2012-09-20 同意一楼观点

读书人网 >软件架构设计

热点推荐