如何在不改变当前页面的情况下设置应用程序的本地化? [英] How to set the localization of the application without changing the current page?
问题描述
我在我的应用程序上使用语言环境,它完美地工作,但问题是,当我在主页 (index.jsp) 中单击应用程序不同页面中的特定语言时,它会转到index.jsp 页面,如何更改映射,以便当我在页面中选择特定语言时,它会保留在该页面中并更改应用程序的语言?如果您需要我上传代码的任何其他部分,请告诉我.
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>
动作
public class LocaleAction extends ActionSupport{
@Override
public String execute(){
return "SUCCESS";
}
}
推荐答案
default
拦截器堆栈包含一个 i18n
拦截器,用于监视 request_locale
参数并根据该参数更改语言环境.所以不需要特殊动作.
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.
要留在同一页面,请使用 <s:url>
标记和 includeParams="all"
和空 value
属性.
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>
这篇关于如何在不改变当前页面的情况下设置应用程序的本地化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!