Class ServletMappingDispatcher

All Implemented Interfaces:
Serializable, Dispatcher

public class ServletMappingDispatcher extends AbstractMappingDispatcher
This servlet-based dispatcher uses the configuration value of the parameter attribute from the corresponding ActionMapping to pick the appropriate method on the action. Because mapping characteristics may differ between the various handlers, actions can be combined in the same class that, differ in their use of method signatures, forms, and/or validation.

For example, a single action may manage a subscription process by defining the following methods:

  • public void create(ActionContext context)
  • public void delete(ActionContext context)
  • public String edit(ActionContext context)
  • public ActionForward list(ActionContext context)
  • public String save(ActionContext context)
for which a corresponding configuration would exist:

  <action path="/createSubscription"
          type="org.example.SubscriptionAction"
          dispatcher="org.apache.struts.dispatcher.servlet.ServletMappingDispatcher"
          parameter="create">
      <forward path="/editSubscription.jsp"/>
  </action>

  <action path="/deleteSubscription"
          type="org.example.SubscriptionAction"
          dispatcher="org.apache.struts.dispatcher.servlet.ServletMappingDispatcher"
          parameter="delete"
          name="subscriptionForm"
          scope="request">
      <forward path="/deletedSubscription.jsp"/>
      <forward name="input" path="/subscription.jsp"
  </action>

  <action path="/editSubscription"
          type="org.example.SubscriptionAction"
          dispatcher="org.apache.struts.dispatcher.servlet.ServletMappingDispatcher"
          parameter="edit">
      <forward path="/editSubscription.jsp"/>
  </action>

  <action path="/listSubscriptions"
          type="org.example.SubscriptionAction"
          dispatcher="org.apache.struts.dispatcher.servlet.ServletMappingDispatcher"
          parameter="list">
      <forward path="/subscriptionList.jsp"/>
  </action>

  <action path="/saveSubscription"
          type="org.example.SubscriptionAction"
          dispatcher="org.apache.struts.dispatcher.servlet.ServletMappingDispatcher"
          parameter="save"
          name="subscriptionForm"
          scope="request"
          validate="true">
      <forward path="/savedSubscription.jsp"/>
      <forward name="input" path="/editSubscription.jsp"
  </action>
 
Since:
Struts 1.4
Version:
$Rev$
See Also:
  • Constructor Details

    • ServletMappingDispatcher

      public ServletMappingDispatcher()
      Constructs a new servlet mapping dispatcher.
  • Method Details

    • unspecified

      protected Object unspecified(ActionContext context) throws Exception
      Sends the 404 HTTP error response.
      Overrides:
      unspecified in class AbstractDispatcher
      Parameters:
      context - the current action context
      Returns:
      always null since the response is handled directly
      Throws:
      Exception - if an error occurs
      See Also:
      • AbstractDispatcher.resolveMethodName(ActionContext)