Class ServletParameterDispatcher

All Implemented Interfaces:
Serializable, Dispatcher

public class ServletParameterDispatcher extends AbstractParameterDispatcher
This servlet-based dispatcher uses the value of the request parameter to pick the appropriate method on the action.

To configure the use of this dispatcher in your configuration, create an entry like below:

 <action path="/saveSubscription"
         type="org.example.SubscriptionAction"
         dispatcher="org.apache.struts.dispatcher.servlet.ServletParameterDispatcher"
         parameter="method"/>
         name="subscriptionForm"
         scope="request"
         input="/subscription.jsp"
 

This example will use the value of the request parameter named "method" to pick the appropriate method. For example, you might have the following three methods in the same action:

  • public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
  • public void insert(ActionContext context)
  • public void update(ServletActionContext context)
and call one of the methods with a URL like this:

http://localhost:8080/myapp/saveSubscription.do?method=update

Since:
Struts 1.4
Version:
$Rev$
See Also:
  • Constructor Details

    • ServletParameterDispatcher

      public ServletParameterDispatcher()
      Constructs a new servlet parameter dispatcher.
  • Method Details

    • resolveParameterValue

      protected String resolveParameterValue(ActionContext context, String parameter)
      Extracts the value from the specified servlet parameter.
      Specified by:
      resolveParameterValue in class AbstractParameterDispatcher
      Parameters:
      context - the current action context
      parameter - the servlet parameter name
      Returns:
      the servlet parameter value
    • 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 the error code fails to set
      See Also:
      • AbstractDispatcher.resolveMethodName(ActionContext)