File Upload and download
Submission Method: Post
The form in which the file is to be uploaded, input type= "file" and must have the Name property
Form type to add Encytype= "Mulitpart/form-data"
How do I get files uploaded by the file?
Use Req.getinputstream in the servlet to get all the request body, after a number of parsing to get the necessary stuff.
FileUpLoad
File: Tian site field
Diskfileitemfactory ();
Servletfileupload
Setfilesizemax (); Set individual file sizes
Setsizemax () set Total file size
SETHEADERENCODINTG (); with req.sercharacterenconding (); a meaning
Ismultipartcontent (req)//Determine if it is a file upload form
Parserequest (req) conversion to list<fileitem> for traversal
Fileitem also have to judge whether it is normal text data Isformfield
GetFileName () Form element name
GetString () the value corresponding to the name of the form element
GetName () file name
getContentType () file type
getInputStream () file stream
Write writes to File
Delete Deletes temporary files
Mailbox
Introducing the Mail.jar Package
Session.getdefaultinstance (Properties file)
The properties file needs to be set
Prop.put ("Mail.transport.protocol", "SMTP"); Specify protocol
Prop.put ("Mail.smtp.host", "localhost"); Host Stmp.qq.com
Prop.put ("Mail.smtp.port", 25); Port
Prop.put ("Mail.smtp.auth", "true"); User Password Authentication
Prop.put ("Mail.debug", "true"); Debug mode
MailMessage (Session)
Setsubject () title
Setsentdate () Send time
Setsender () Send address
Setrecipient () Receiver
SetText () Send content
Settransport ()
Connect () Send
SendMessage ()
Close ();
Multi-User mail
Mimemultipart ("related")
Addbodypart ()
MimeBodyPart ();
Setdatahandler (New DataHandler (New Filedatasource (path)))
Setcontentid (); Set resource Name
SetContent () Setting content text
Message setcontent (related); Add to Message last send
File Upload and download/mail