简体   繁体   中英

I18n redirection issue in struts2 web application

In my application Locale is dynamically selected by user from login page and I am saving selected locale in Cookie.

I am facing I18n related problem in case of redirection in my web application.

When I redirect a page by URL by appending current locale then my application language remains same as selected language(ie working fine in this case), but when I redirect to next page by struts redirection defined in struts.xml file the locale changes to the default value(English in my case).

For example:

In case of- <result name="success" type="redirect"> , locale changes to default one.

In case I remove type=redirect then its working fine but my form will be submitted two times.

So is there any way to append locale to struts redirection at runtime?

Here is one of my interceptor stack:

<interceptor-stack name="sessionValidateStack">
    <interceptor-ref name="auditTrail"></interceptor-ref>
    <interceptor-ref name="sessionCheck"></interceptor-ref>
    <interceptor-ref name="service">
        <param name="code">DG</param>
        <param name="interfaceType">WEB</param>
    </interceptor-ref>
    <interceptor-ref name="defaultStack"></interceptor-ref>
    <interceptor-ref name="expHandler"></interceptor-ref>
</interceptor-stack>

在参数中添加request_locale=<your_language_key>

Use redirect-action instead of redirect in action result type because in case of redirect action,control jumps to the different action(in same or other package).

Please refer link for the difference between redirect and redirect type result type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM