Forcing Add / Type OGNL

%{control.current + #displayRows}

- This is ultimately the statement that I need to fulfill. I have it in the s: if tag, and I use a test to see if this value is in a specific range.

Ultimately, I get string concatenation rather than appending, because both sides of the complement are not considered as numeric OGNL types. Catching a little, I see that

%{control.current + control.current}

leads to a numerical addition, so the value of displayRows, which was set earlier in the s: set tag, is really considered a non-numeric value. Here is my s: set tag:

<s:set name="displayRows" value="%{#application['app_settings'].settings['MAX ACCESS FIELD TITLES ROWS']}" />

Settings are a map in Java. While the key is always a string ... well ... the value is not always an integer because various application settings are stored. Therefore, for a value type, it is best to use Object. And I think this is a problem. OGNL does not consider this to be something that can be automatically converted to a numeric type.

langauge http://incubator.apache.org/ognl/language-guide.html, , OGNL ", displayRows, 15 REALLY, ". . , , . OGNL, s: set Java, , .

+3
1

Struts , #displayRows - String, Integer ( , ).

struts.xml.

struts.xml, - , :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.devMode" value="true" />
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.date.format" value="0,date,dd.MM.yyyy"/>
    <constant name="format.date" value="{0,date,dd.MM.yyyy}"/>
    <constant name="struts.ognl.allowStaticMethodAccess" value="true"/> 
</struts>

jsp - :

<s:property value='@java.lang.Integer@valueOf("123") + @java.lang.Integer@valueOf("123")' />

: 246

, set:

<s:set name="displayRows" value="@java.lang.Integer@valueOf(#application['app_settings'].settings['MAX ACCESS FIELD TITLES ROWS'])" />

<s:property value="control.current + #displayRows"/>

, .

+6

All Articles