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

s:form tag doesn't handle dynamic method invocation, it sets action value to action!method!method.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.1.0, 2.1.1, 2.1.2
    • 2.1.3
    • Core Actions
    • None
    • Patch, Important

    Description

      <s:form action="action!method" ...> renders as: <form action="action!method!method" ...>

      The bug was introduced in ServletUrlRenderer in 590812 revision.

      action variable used to be equivalent to actionName:

      • // handle "name!method" convention.
      • if (formComponent.enableDynamicMethodInvocation) {
      • if (action.indexOf("!") != -1) { - int endIdx = action.lastIndexOf("!"); - actionMethod = action.substring(endIdx + 1, action.length()); //this removes !method from action's value: - action = action.substring(0, endIdx); - }
      • }
        ...
      • String actionName = action;

      Since this revision action variable may contain DMI mark (i.e. SomeAction!edit). This value is passed down the road to ActionMapping constructor (and other methods that expect pure action name):
      ActionMapping mapping = new ActionMapping(action, namespace, actionMethod, formComponent.parameters);
      With DMI call looks like:
      new ActionMapping('SomeAction!edit!edit', '/', 'edit', ...)
      This results in an s:form tag's action attribute equal to 'SomeAction!edit!edit'.

      Attachments

        1. form_dmi.patch
          5 kB
          Lukasz Racon

        Issue Links

          Activity

            People

              wesw@wantii.com Wes Wannemacher
              lukaszracon Lukasz Racon
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: