Problem Description: When a post is requested, the picture is passed into the background in file format and is saved as a. tmp format.
Solution:
Private File userfile;private String userfilefilename;private string Userfilecontenttype;public string Getuserfilefilename () {return userfilefilename;} public void Setuserfilefilename (String userfilefilename) {userfilefilename = Userfilefilename;} Public String Getuserfilecontenttype () {return userfilecontenttype;} public void Setuserfilecontenttype (String userfilecontenttype) {userfilecontenttype = Userfilecontenttype;} Public File Getuserfile () {return userfile;} public void Setuserfile (File userfile) {userfile = UserFile;}
As above, when declaring the private File userfile, do not forget to declare the corresponding Userfilefilename and Userfilefilecontenttype (these two variables will be automatically assigned by struts), Use the Userfilefilename variable to avoid errors when using the file name of the uploaded file in the code that uploads it later.
Struts2 upload image suffix name to. tmp