Negative integer request parameters not recognized when language is Arabic, other languages like english, german, french & chinese work fine

安稳与你 提交于 2020-01-16 00:41:06

问题


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:


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.



来源:https://stackoverflow.com/questions/19875848/negative-integer-request-parameters-not-recognized-when-language-is-arabic-othe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!