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

Not set parameter value to Action correctlly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4.1, 2.3.7
    • Fix Version/s: 2.3.28, 2.5
    • Component/s: Core Actions
    • Labels:
      None
    • Environment:

      JDK: 1.6.0_37
      AS: Tomcat 7.0.22

      Description

      Sample code:

      import com.opensymphony.xwork2.ActionSupport;
      public class HelloAction extends ActionSupport {
          private String pName;
          public String execute() {
              return SUCCESS;
          }
          public String getpName() {
              return pName;
          }
          public void setpName(String pName) {
              this.pName = pName;
          }
      }
      

      I can't set param's value use url '

      {contextPath}

      /hello.action?pName=111'.

      According to JavaBeans Spec sec 8.8 "Capitalization of inferred names":

      Thus when we extract a property or event name from the middle of an existing Java name, we normally convert the first character to lower case. However to support the occasional use of all upper-case names, we check if the first two characters of the name are both upper case and if so leave it alone. So for example,
      “FooBah” becomes “fooBah”
      “Z” becomes “z”
      “URL” becomes “URL”
      We provide a method Introspector.decapitalize which implements this conversion rule.

      String java.beans.Introspector.decapitalize(String name)

      Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

      Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

        Issue Links

          Activity

          Hide
          mlw5415 lwen.ma added a comment -

          This is bug of OGNL, the follow code can reproduce the case:

          import ognl.Ognl;
          import ognl.OgnlException;

          public class OgnlTest {

          public static void main(String[] args) {
          HelloAction action = new HelloAction();
          action.setpName("pName.Foo");

          try

          { Object pName = Ognl.getValue("pName", action); System.out.println(pName); }

          catch (OgnlException e)

          { e.printStackTrace(); }

          }
          }

          Show
          mlw5415 lwen.ma added a comment - This is bug of OGNL, the follow code can reproduce the case: import ognl.Ognl; import ognl.OgnlException; public class OgnlTest { public static void main(String[] args) { HelloAction action = new HelloAction(); action.setpName("pName.Foo"); try { Object pName = Ognl.getValue("pName", action); System.out.println(pName); } catch (OgnlException e) { e.printStackTrace(); } } }
          Hide
          mlw5415 lwen.ma added a comment -

          Upload a diff file for patch, hope this issue be fixed more quickly,tks.

          Show
          mlw5415 lwen.ma added a comment - Upload a diff file for patch, hope this issue be fixed more quickly,tks.
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Could you prepare a pull request?

          Show
          lukaszlenart Lukasz Lenart added a comment - Could you prepare a pull request?
          Hide
          mlw5415 lwen.ma added a comment -

          I may try, although I hadn't use git before, give me the git address plz.

          Show
          mlw5415 lwen.ma added a comment - I may try, although I hadn't use git before, give me the git address plz.
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          https://github.com/jkuhnert/ognl - fork, clone locally, apply your changes, push, go to GitHub, select your commits and prepare pull request

          Show
          lukaszlenart Lukasz Lenart added a comment - https://github.com/jkuhnert/ognl - fork, clone locally, apply your changes, push, go to GitHub, select your commits and prepare pull request
          Hide
          lukaszlenart Lukasz Lenart added a comment -
          Show
          lukaszlenart Lukasz Lenart added a comment - Pull request https://github.com/jkuhnert/ognl/pull/6
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          OGNL 3.0.8 released - under way to the Central

          Show
          lukaszlenart Lukasz Lenart added a comment - OGNL 3.0.8 released - under way to the Central
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Thanks for the patch!

          Show
          lukaszlenart Lukasz Lenart added a comment - Thanks for the patch!

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              mlw5415 lwen.ma
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development