struts2action-mapping

What is the role of the action mapper in Struts 2?


Can somebody explain the role of the Action Mapper in Struts 2?


Solution

  • The role of ActionMapper interface in Struts2 framework is to extract mapping from the request's URL.

    When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches, or it may return an ActionMapping class that describes an action invocation for the framework to try.

    You can read more about this feature here.

    Th first method returns a mapping to try, it doesn't guarantee that this action will be executed.

    The ActionMapping returned by the action mapper contains all necessary information to invoke an action if there's an action config corresponding to this mapping is available in runtime configuration.

    Different implementation of this interface can be used to override the default behavior for mapping URLs to actions in Struts2.