commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thim Anneessens (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (OGNL-235) Problem with expressions mixing arithmetic and string concatenation
Date Tue, 21 May 2013 09:39:21 GMT

     [ https://issues.apache.org/jira/browse/OGNL-235?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thim Anneessens updated OGNL-235:
---------------------------------

    Description: 
The following behavior is strange:

OGNL Expression: "Your number is "+(3+1)
Resulting output: Your number is 31
Expected output: Your number is 4

OGNL Expression: (3+1)+" is my number"
Resulting output: 4 is your number

This pretty much sums the problem ;).

Here is an illustration of that problem with struts2:

         <s:property value="'Test ' + (1+1)"/>

will output

         Test 11

so 1+1 is evaluated as a string concatenation.

          <s:property value="(1+1) + 'Test'"/>

will output

          2 Test

so 1+1 is evaluated as a sum


The latter evaluation seems to be the right one, as there are parenthesis around "1+1".


Thanks in advance for looking into this.

Thim.

  was:
The following behavior is strange:

OGNL Expression: "Your number is "+(3+1)
Resulting output: Your number is 31
Expected output: Your number is 4

OGNL Expression: (3+1)+" is my number"
Resulting output: 4 is your number

This pretty much sums the problem ;).

Here is an illustration of that problem with struts2:

{code:html}
<s:property value="'Test ' + (1+1)"/>
{code}
will output
{code:html}
Test 11
{code}
so 1+1 is evaluated as a string concatenation.

{code:html}
<s:property value="(1+1) + 'Test'"/>
{code}
will output
{code:html}
2 Test
{code}
so 1+1 is evaluated as a sum

The latter evaluation seems to be the right one, as there are parenthesis around "1+1".


Thanks in advance for looking into this.
Thim.

    
> Problem with expressions mixing arithmetic and string concatenation
> -------------------------------------------------------------------
>
>                 Key: OGNL-235
>                 URL: https://issues.apache.org/jira/browse/OGNL-235
>             Project: Commons OGNL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Thim Anneessens
>
> The following behavior is strange:
> OGNL Expression: "Your number is "+(3+1)
> Resulting output: Your number is 31
> Expected output: Your number is 4
> OGNL Expression: (3+1)+" is my number"
> Resulting output: 4 is your number
> This pretty much sums the problem ;).
> Here is an illustration of that problem with struts2:
>          <s:property value="'Test ' + (1+1)"/>
> will output
>          Test 11
> so 1+1 is evaluated as a string concatenation.
>           <s:property value="(1+1) + 'Test'"/>
> will output
>           2 Test
> so 1+1 is evaluated as a sum
> The latter evaluation seems to be the right one, as there are parenthesis around "1+1".
> Thanks in advance for looking into this.
> Thim.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message