Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

jsp - How to set the localization of the application without changing the current page?

I am using locale on my application, it perfectly works, but the problem is that, when I am in the main page (index.jsp) when I click on a specific language in different pages of the application, it goes to index.jsp page, how can I change the mapping so when I select a specific language in a page it stays in that page and change the language of the application ? please let me know if you need me to upload any other part of the code.

Struts.xml

<action name="locale" class="com.myapp.struts.LocaleAction">
  <result name="SUCCESS" type="tiles">baseLayout</result>
</action>

Action

public class LocaleAction extends ActionSupport{

    @Override
    public String execute(){
        return "SUCCESS";
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The default interceptor stack includes an i18n interceptor that watches for the request_locale parameter and changes locale based on that parameter. So there is no need for special action.

For staying in the same page use <s:url> tag with includeParams="all" and empty value attribute.

<s:url var="urlen" includeParams="all" value="">
  <s:param name="request_locale">en</s:param>
</s:url>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...