Struts2 upload image suffix name to. tmp

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.