Class JakartaMultiPartRequest
java.lang.Object
org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest
- All Implemented Interfaces:
MultiPartRequest
Multipart form data request adapter for Jakarta Commons Fileupload package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
BUFFER_SIZE, bufferSize, defaultEncoding, defaultLocale, errors, maxFiles, maxFileSize, maxSize, maxStringLength, STRUTS_MESSAGES_UPLOAD_ERROR_PARAMETER_TOO_LONG_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp()
Cleans up all uploaded file, should be called at the end of requestprotected org.apache.commons.fileupload2.core.DiskFileItemFactory
createDiskFileItemFactory
(String saveDir) protected org.apache.commons.fileupload2.core.RequestContext
createRequestContext
(jakarta.servlet.http.HttpServletRequest req) Creates a RequestContext needed by Jakarta Commons Upload.protected org.apache.commons.fileupload2.jakarta.JakartaServletFileUpload
createServletFileUpload
(org.apache.commons.fileupload2.core.DiskFileItemFactory fac) String[]
getContentType
(String fieldName) Returns the content type(s) of the file(s) associated with the specified field name (as supplied by the client browser), or null if no files are associated with the given field name.Returns aUploadedFile
object for the filename specified or null if no files are associated with the given field name.String[]
getFileNames
(String fieldName) Returns a String[] of file names for files associated with the specified input field nameReturns an enumeration of the parameter names for uploaded filesString[]
getFilesystemName
(String fieldName) Returns the file system name(s) of files associated with the given field name or null if no files are associated with the given field name.getParameter
(String name) Returns the specified request parameter.Returns an enumeration of String parameter names.String[]
getParameterValues
(String name) Returns a list of all parameter values associated with a parameter name.void
Creates a new request wrapper to handle multipart data using methods adapted from Jason Pell's multipart classes (see class description).protected List<org.apache.commons.fileupload2.core.FileItem>
parseRequest
(jakarta.servlet.http.HttpServletRequest servletRequest, String saveDir) protected void
processFileField
(org.apache.commons.fileupload2.core.FileItem item) protected void
processNormalFormField
(org.apache.commons.fileupload2.core.FileItem item, String charset) protected void
processUpload
(jakarta.servlet.http.HttpServletRequest request, String saveDir) Methods inherited from class org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
buildErrorMessage, getCanonicalName, getErrors, setBufferSize, setDefaultEncoding, setLocale, setLocaleProviderFactory, setMaxFiles, setMaxFileSize, setMaxSize, setMaxStringLength
-
Field Details
-
files
-
params
-
-
Constructor Details
-
JakartaMultiPartRequest
public JakartaMultiPartRequest()
-
-
Method Details
-
parse
public void parse(jakarta.servlet.http.HttpServletRequest request, String saveDir) throws IOException Creates a new request wrapper to handle multipart data using methods adapted from Jason Pell's multipart classes (see class description).- Parameters:
saveDir
- the directory to save off the filerequest
- the request containing the multipart- Throws:
IOException
- is thrown if encoding fails.
-
processUpload
protected void processUpload(jakarta.servlet.http.HttpServletRequest request, String saveDir) throws IOException - Throws:
IOException
-
processFileField
protected void processFileField(org.apache.commons.fileupload2.core.FileItem item) -
processNormalFormField
protected void processNormalFormField(org.apache.commons.fileupload2.core.FileItem item, String charset) throws IOException - Throws:
IOException
-
parseRequest
protected List<org.apache.commons.fileupload2.core.FileItem> parseRequest(jakarta.servlet.http.HttpServletRequest servletRequest, String saveDir) throws org.apache.commons.fileupload2.core.FileUploadException - Throws:
org.apache.commons.fileupload2.core.FileUploadException
-
createServletFileUpload
protected org.apache.commons.fileupload2.jakarta.JakartaServletFileUpload createServletFileUpload(org.apache.commons.fileupload2.core.DiskFileItemFactory fac) -
createDiskFileItemFactory
protected org.apache.commons.fileupload2.core.DiskFileItemFactory createDiskFileItemFactory(String saveDir) -
getFileParameterNames
Description copied from interface:MultiPartRequest
Returns an enumeration of the parameter names for uploaded files- Returns:
- an enumeration of the parameter names for uploaded files
-
getContentType
Description copied from interface:MultiPartRequest
Returns the content type(s) of the file(s) associated with the specified field name (as supplied by the client browser), or null if no files are associated with the given field name.- Parameters:
fieldName
- input field name- Returns:
- an array of content encoding for the specified input field name or null if no content type was specified.
-
getFile
Description copied from interface:MultiPartRequest
Returns aUploadedFile
object for the filename specified or null if no files are associated with the given field name.- Parameters:
fieldName
- input field name- Returns:
- a UploadedFile[] object for files associated with the specified input field name
-
getFileNames
Description copied from interface:MultiPartRequest
Returns a String[] of file names for files associated with the specified input field name- Parameters:
fieldName
- input field name- Returns:
- a String[] of file names for files associated with the specified input field name
-
getFilesystemName
Description copied from interface:MultiPartRequest
Returns the file system name(s) of files associated with the given field name or null if no files are associated with the given field name.- Parameters:
fieldName
- input field name- Returns:
- the file system name(s) of files associated with the given field name
-
getParameter
Description copied from interface:MultiPartRequest
Returns the specified request parameter.- Parameters:
name
- the name of the parameter to get- Returns:
- the parameter or null if it was not found.
-
getParameterNames
Description copied from interface:MultiPartRequest
Returns an enumeration of String parameter names.- Returns:
- an enumeration of String parameter names.
-
getParameterValues
Description copied from interface:MultiPartRequest
Returns a list of all parameter values associated with a parameter name. If there is only one parameter value per name the resulting array will be of length 1.- Parameters:
name
- the name of the parameter.- Returns:
- an array of all values associated with the parameter name.
-
createRequestContext
protected org.apache.commons.fileupload2.core.RequestContext createRequestContext(jakarta.servlet.http.HttpServletRequest req) Creates a RequestContext needed by Jakarta Commons Upload.- Parameters:
req
- the request.- Returns:
- a new request context.
-
cleanUp
public void cleanUp()Description copied from interface:MultiPartRequest
Cleans up all uploaded file, should be called at the end of request
-