Package org.apache.struts2.dispatcher
Class PrepareOperations
java.lang.Object
org.apache.struts2.dispatcher.PrepareOperations
Contains preparation operations for a request before execution
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAssigns the dispatcher to the dispatcher thread localvoidCleans up the dispatcher instancevoidcleanupRequest(jakarta.servlet.http.HttpServletRequest request) Cleans up request.voidcleanupWrappedRequest(jakarta.servlet.http.HttpServletRequest request) Should be called after wheneverwrapRequest(jakarta.servlet.http.HttpServletRequest)is called.static voidClear any override of the static devMode value being applied to the current thread.createActionContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Creates the action context and initializes the thread localstatic voiddecrementRecursionCounter(jakarta.servlet.http.HttpServletRequest request, String attributeName, Runnable runnable) Helper method to count execution completions with a request attribute, and optionally execute some code (e.g.findActionMapping(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Finds and optionally creates anActionMapping.findActionMapping(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean forceLookup) Finds and optionally creates anActionMapping.static Booleanstatic voidincrementRecursionCounter(jakarta.servlet.http.HttpServletRequest request, String attributeName) Helper method to potentially count recursive executions with a request attribute.booleanisUrlExcluded(jakarta.servlet.http.HttpServletRequest request) Check whether the request matches a list of exclude patterns.static voidoverrideDevMode(boolean devMode) Set an override of the static devMode value.voidsetEncodingAndLocale(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sets the request encoding and locale on the responsevoidtrackRecursion(jakarta.servlet.http.HttpServletRequest request) Should be called byStrutsPrepareFilterto track how many times this request has been filtered.jakarta.servlet.http.HttpServletRequestwrapRequest(jakarta.servlet.http.HttpServletRequest request) Wraps the request with the Struts wrapper that handles multipart requests better Also tracks additional calls to this method on the same request.
- 
Constructor Details- 
PrepareOperations
 
- 
- 
Method Details- 
trackRecursionpublic void trackRecursion(jakarta.servlet.http.HttpServletRequest request) Should be called byStrutsPrepareFilterto track how many times this request has been filtered.
- 
cleanupRequestpublic void cleanupRequest(jakarta.servlet.http.HttpServletRequest request) Cleans up request. When paired withtrackRecursion(jakarta.servlet.http.HttpServletRequest), only cleans up once the first filter instance has completed, preventing cleanup by recursive filter calls - i.e. before the request is completely processed.
- 
createActionContextpublic ActionContext createActionContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Creates the action context and initializes the thread local- Parameters:
- request- servlet request
- response- servlet response
- Returns:
- the action context
 
- 
assignDispatcherToThreadpublic void assignDispatcherToThread()Assigns the dispatcher to the dispatcher thread local
- 
setEncodingAndLocalepublic void setEncodingAndLocale(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sets the request encoding and locale on the response- Parameters:
- request- servlet request
- response- servlet response
 
- 
wrapRequestpublic jakarta.servlet.http.HttpServletRequest wrapRequest(jakarta.servlet.http.HttpServletRequest request) throws jakarta.servlet.ServletException Wraps the request with the Struts wrapper that handles multipart requests better Also tracks additional calls to this method on the same request.- Parameters:
- request- servlet request
- Returns:
- The new request, if there is one
- Throws:
- jakarta.servlet.ServletException- on any servlet related error
 
- 
cleanupWrappedRequestpublic void cleanupWrappedRequest(jakarta.servlet.http.HttpServletRequest request) Should be called after wheneverwrapRequest(jakarta.servlet.http.HttpServletRequest)is called. Ensures the request is only cleaned up at the instance it was initially wrapped in the case of multiple wrap calls - i.e. filter recursion.
- 
findActionMappingpublic ActionMapping findActionMapping(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Finds and optionally creates anActionMapping. It first looks in the current request to see if one has already been found, otherwise, it creates it and stores it in the request. No mapping will be created in the case of static resource requests or unidentifiable requests for other servlets, for example.- Parameters:
- request- servlet request
- response- servlet response
- Returns:
- the action mapping
 
- 
findActionMappingpublic ActionMapping findActionMapping(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean forceLookup) Finds and optionally creates anActionMapping. if forceLookup is false, it first looks in the current request to see if one has already been found, otherwise, it creates it and stores it in the request. No mapping will be created in the case of static resource requests or unidentifiable requests for other servlets, for example.- Parameters:
- forceLookup- if true, the action mapping will be looked up from the ActionMapper instance, ignoring if there is one in the request or not
- request- servlet request
- response- servlet response
- Returns:
- the action mapping
 
- 
cleanupDispatcherpublic void cleanupDispatcher()Cleans up the dispatcher instance
- 
isUrlExcludedpublic boolean isUrlExcluded(jakarta.servlet.http.HttpServletRequest request) Check whether the request matches a list of exclude patterns.- Parameters:
- request- The request to check patterns against
- Returns:
- true if the request URI matches one of the given patterns
 
- 
overrideDevModepublic static void overrideDevMode(boolean devMode) Set an override of the static devMode value. Do not set this via a request parameter or any other unprotected method. Using a signed cookie is one safe way to turn it on per request.- Parameters:
- devMode- the override value
 
- 
getDevModeOverride- Returns:
- Boolean override value, or null if no override
 
- 
clearDevModeOverridepublic static void clearDevModeOverride()Clear any override of the static devMode value being applied to the current thread. This can be useful for any situation whereoverrideDevMode(boolean)might be called in a flow wherecleanupRequest(jakarta.servlet.http.HttpServletRequest)does not get called. May be very situational (such as some unit tests), but may have other utility as well.
- 
incrementRecursionCounterpublic static void incrementRecursionCounter(jakarta.servlet.http.HttpServletRequest request, String attributeName) Helper method to potentially count recursive executions with a request attribute. Should be used in conjunction withdecrementRecursionCounter(jakarta.servlet.http.HttpServletRequest, java.lang.String, java.lang.Runnable).
- 
decrementRecursionCounterpublic static void decrementRecursionCounter(jakarta.servlet.http.HttpServletRequest request, String attributeName, Runnable runnable) Helper method to count execution completions with a request attribute, and optionally execute some code (e.g. cleanup) once all recursive executions have completed. Should be used in conjunction withincrementRecursionCounter(jakarta.servlet.http.HttpServletRequest, java.lang.String).
 
-