Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4131

RestActionProxyFactory is handling all requests with PrefixBasedActionMapper

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.12, 2.3.14, 2.3.15
    • 2.3.16
    • Plugin - REST
    • None

    Description

      Using the following configuration:

      <constant name="struts.mapper.class" value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/>
      <constant name="struts.mapper.prefixMapping" value=":rest,/ajax:struts,/login:struts"/>
      

      Is expected that when I request the following url http://xxxxxxxx.com/ajax/anyThingHere, struts action proxy should handle this call. But instead, RestActionProxyFactory is handling this call.

      But the RestActionProxyFactory class has a if, and every time the namespace attribute is injected with "/ajax" value. So the condition always is redirected to the rest plugin handler and not to the struts default.

      Here is my ActionProxyFactory implementation:

      public class CustomActionProxyFactory extends RestActionProxyFactory {
      
          @Override
          public ActionProxy createActionProxy(String namespace, String actionName, String methodName, Map<String, Object> extraContext, boolean executeResult, boolean cleanupContext) {
              RestActionProxyFactory p = new RestActionProxyFactory();
              p.setContainer(container);
              if ("/ajax".equals(namespace)) {
                  p.setNamespace("/idealogic");
              }
              return p.createActionProxy(namespace, actionName, methodName, extraContext, executeResult, cleanupContext);
          }
      }
      

      By some reason, it fixed the origin behaviour.

      The begin of this issue was that <s:action> tag was rendering the action result, even with executeResult = false, which is the default value.

      Another observation was that, changing the flush attribute value, the result is rendered in different parts of the html.

      Attachments

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              felipe.lorenz Felipe Lorenz
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: