I have to have 2 normal text fields and 1 upload field to be parsed. In addition, if I use HTML code JSP code: First of all, you are repeating the form fields, and for each Setting the second, both Consider. In short, if it is a simple form, use If this is a file, then there are detailed options in the links given above. getFieldName (); As suggested, only the name attribute of the
input html tag is not received and the parameter is not entered.
GetRelDate = fi.getFieldName (); The result of 'date' in is the result.
getFieldName () for both common code, they are of the same result
& lt;! - Normal text field - & gt; & Lt; Td> Release date & lt; / Td> & Lt; Td> & Lt; Input type = 'text' size = 30 name = 'date' & gt; & Lt; / Td> & Lt; TD & gt; Apple & lt; / TD & gt; & Lt; Td> & Lt; Input type = 'text' size = 30 name = 'apple' & gt; & Lt; / Td> & Lt ;! - Upload field - & gt; & Lt; Td> Image Upload & lt; / Td> & Lt; Td> & Lt; Input type = 'file' size = 30 name = 'image file' & gt; & Lt; / Td>
string getRelDate = ""; String getApple = ""; Try to get the // // file item to parse the request list file items = uploads. Equality Request (request); // Process Iterator i = fileItems.iterator () on uploaded file items; While (i.hasNext ()) {FileItem fi = (FileItem) i.next (); If (fi.isFormField ()) {getRelDate = fi.getFieldName (); GetApple = fi.getFieldName (); } // Retrieve uploaded file parameters file2 = new file (filePath, fi.getName ()); Fi.write (make 2); Out.println ("Uploaded Filename:" + FilePath +++ Fi.getName () + "& lt; br & gt;"); }}
getRelDate and
getApple to the field name. Second, you are setting the field value instead of the field name .
getString () to return the field content.
No comments:
Post a Comment