Small problems in the STRUTS2

Source: Internet
Author: User

is learning Struts2 and discovering a very important thing. Written here, mainly to remind me and everyone.

That is in the Struts2, as long as it involves the operation of data transmission, you must remember to write the Getter/setter method. It was not a problem, but I did it on his shameless forget!

The following is a code for uploading files.

 PackageAction;ImportJava.io.File;Importjava.io.IOException;Importorg.apache.commons.io.FileUtils;ImportOrg.apache.struts2.ServletActionContext;ImportCom.opensymphony.xwork2.ActionSupport; Public classFileupactionextendsActionsupport {PrivateString Fifilename;//file name    PrivateString Ficontenttype;//File Type    PrivateFile fi;//File Contents             PublicString Fileup () {//The first path to the serverString path = Servletactioncontext.getservletcontext (). Getrealpath ("/"); //new A File objectFile File =NewFile (NewFile (path), fifilename); //Copy Picture        Try{fileutils.copyfile (fi, file); } Catch(IOException e) {e.printstacktrace (); }                return"Pass"; }}

Small problems in the STRUTS2

Related Article

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.