struts2 上传文件 错误记录

struts2 上传文件form中添加

<input type="file" name="file"/>

在action中需要有三个属性

private File file;
private String contentType;
private String fileName;
 

分别实现其setter方法,但是contentType和fileName的实现方法有所不同

就是方法名前要以file属性的setter名字开头

public void setFileContentType()
public void setFileFileName()
 
扫描二维码关注公众号,回复: 742041 查看本文章

ps.试验过程中,一直获得不到方法名,后来发现fileName写成filename,就差一个字母,看来这个字母不能随便起名字的.


猜你喜欢

转载自hongfei-sr.iteye.com/blog/1138230