Negative integer request parameters not recognized

2019-08-14 09:03发布

I have a struts2 web-application.

When I change the language to arabic, all query string urls, give un-certain results. I guess that's because ? is considered to be some variable name and then it's not mapped properly to the target action by Struts2.

Although examples present on internet seems to work fine, so I guess this has something to do with my struts configuration.

<constant name="struts.devMode" value="false" />
    <constant name="struts.ognl.allowStaticMethodAccess" value="true"/>

    <constant name="struts.custom.i18n.resources" value="struts,global"/>
<!--    <constant name="struts.action.extension" value="" />-->

    <constant name="struts.enable.SlashesInActionNames" value="true"/>
    <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
    <constant name="struts.patternMatcher" value="regex" />

As long as the language is english, url like http://localhost:8084/myaction?id=4 works perfectly fine and returns the required data but once the language is changed, that url bound action is never called, instead some other random action is being called.

[UPDATE]

Random actions are not called. Actually, the parameters don't get mapped and hence, due to validation checks in the action, the action returns INPUT. But the same url works when language is English i.e. parameters gets mapped perfectly and success is returned.

[UPDATE 2]

<interceptor-stack name="rememberMeStack">
                <interceptor-ref name="rememberme"/>
                <interceptor-ref name="defaultStack"/>
                <interceptor-ref name="store">
                    <param name="operationMode">AUTOMATIC</param>
                </interceptor-ref>
            </interceptor-stack>

Above is the interceptor stack I'm using.

[UPDATE 3]

http://localhost:8084/search?id=-1&...

Only parameters with value -1 are giving OGNL exception Error Setting Expression, rest numbers seems to work fine.

[UPDATE 4]

I've tried using more languages and figured out that, it's not working ONLY for arabic languages. I guess it has something to do with their left-right alignment.

I also managed to write a small sample application, which demonstrates that only when language is arabic, the form submission gives error & with other any other language (english, chinese, french) it works fine.

I have also filed a bug on struts2 jira for this - https://issues.apache.org/jira/browse/WW-4241

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-14 09:34

Actually it is very simple: Arabic is right to left script. So your -1 is actually 1- (and a String) you need to input 1- to post negative integers.

查看更多
登录 后发表回答