JSP:
<html:file property="path" styleClass="text2" />
action:
BookForm bookForm = (BookForm) form;
bookForm.getPath();
为什么有的时候是绝对路径,有的时候只显示文件名.扩展名呢?我就要绝对路径,有什么好办法吗?
<html:file property="path" styleClass="text2" />
action:
BookForm bookForm = (BookForm) form;
bookForm.getPath();
为什么有的时候是绝对路径,有的时候只显示文件名.扩展名呢?我就要绝对路径,有什么好办法吗?
参照: File imageFile = new File(ServletActionContext.getServletContext().getRealPath( " /UploadImages " ) + " / " + imageFileName);
" /UploadImages "是你要把文件上传到你服务器的哪个文件夹下(根目录)
imageFileName是你的bookForm.getPath()得到的值。
就可以获取绝对路径了。。