jsp 代码
后台代码:
private File upload;
private String filename;
private String pwd;
public String upload() throws Exception{
File uploadFile = new File(ServletActionContext.getServletContext().getRealPath("upload"));
if(!uploadFile.exists()) {
uploadFile.mkdir();
}
System.out.println(pwd);
System.out.println(upload);
System.out.println(filename);
只有pwd有数据,upload,filename
帮忙看看,谢谢,
你前台提交表单属性注意看下,是否还是普通的表达提交,那样只能获取到文件名,而不是文件本身。
要修改form表单属性,enctype="multipart/form-data"
可以参考一下这个网站:http://www.yiibai.com/struts_2/struts-2-download-file-example.html
enctype="multipart/form-data"
是不是没有get和set方法呀,我也是这个问题,找了一下午