org.apache.struts2.dispatcher

## Class PrepareOperations

- java.lang.Object
- - org.apache.struts2.dispatcher.PrepareOperations

-     public class PrepareOperations
      extends Object

  Contains preparation operations for a request before execution

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CLEANUP_RECURSION_COUNTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrepareOperations(Dispatcher dispatcher)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assignDispatcherToThread()` Assigns the dispatcher to the dispatcher thread local
    `void` | `cleanupDispatcher()` Cleans up the dispatcher instance
    `void` | `cleanupRequest(javax.servlet.http.HttpServletRequest request)` Cleans up a request of thread locals
    `ActionContext` | `createActionContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Creates the action context and initializes the thread local
    `ActionMapping` | `findActionMapping(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Finds and optionally creates an `ActionMapping`.
    `ActionMapping` | `findActionMapping(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean forceLookup)` Finds and optionally creates an `ActionMapping`.
    `static Boolean` | `getDevModeOverride()`
    `boolean` | `isUrlExcluded(javax.servlet.http.HttpServletRequest request, List<Pattern> excludedPatterns)` Check whether the request matches a list of exclude patterns.
    `static void` | `overrideDevMode(boolean devMode)` Set an override of the static devMode value.
    `void` | `setEncodingAndLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Sets the request encoding and locale on the response
    `javax.servlet.http.HttpServletRequest` | `wrapRequest(javax.servlet.http.HttpServletRequest oldRequest)` Wraps the request with the Struts wrapper that handles multipart requests better

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CLEANUP_RECURSION_COUNTER

          public static final String CLEANUP_RECURSION_COUNTER

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PrepareOperations

          public PrepareOperations(Dispatcher dispatcher)

  - ### Method Detail

    - #### createActionContext

          public ActionContext createActionContext(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)

      Creates the action context and initializes the thread local
      Parameters:
        `request` - servlet request
        `response` - servlet response
      Returns:
        the action context

    - #### cleanupRequest

          public void cleanupRequest(javax.servlet.http.HttpServletRequest request)

      Cleans up a request of thread locals
      Parameters:
        `request` - servlet request

    - #### assignDispatcherToThread

          public void assignDispatcherToThread()

      Assigns the dispatcher to the dispatcher thread local

    - #### setEncodingAndLocale

          public void setEncodingAndLocale(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)

      Sets the request encoding and locale on the response
      Parameters:
        `request` - servlet request
        `response` - servlet response

    - #### wrapRequest

          public javax.servlet.http.HttpServletRequest wrapRequest(javax.servlet.http.HttpServletRequest oldRequest)
                                                            throws javax.servlet.ServletException

      Wraps the request with the Struts wrapper that handles multipart requests better
      Parameters:
        `oldRequest` - servlet request
      Returns:
        The new request, if there is one
      Throws:
        `javax.servlet.ServletException` - on any servlet related error

    - #### findActionMapping

          public ActionMapping findActionMapping(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)

      Finds and optionally creates an `ActionMapping`. 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

    - #### findActionMapping

          public ActionMapping findActionMapping(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        boolean forceLookup)

      Finds and optionally creates an `ActionMapping`. 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

    - #### cleanupDispatcher

          public void cleanupDispatcher()

      Cleans up the dispatcher instance

    - #### isUrlExcluded

          public boolean isUrlExcluded(javax.servlet.http.HttpServletRequest request,
                              List<Pattern> excludedPatterns)

      Check whether the request matches a list of exclude patterns.
      Parameters:
        `request` - The request to check patterns against
        `excludedPatterns` - list of patterns for exclusion
      Returns:
        `true` if the request URI matches one of the given patterns

    - #### overrideDevMode

          public 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

          public static Boolean getDevModeOverride()

      Returns:
        Boolean override value, or null if no override

Copyright © 2000–2019 Apache Software Foundation. All rights reserved.