如何在不更改当前页面的情况下设置应用程序的本地化? [英] 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
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.
要停留在同一页面上,请使用带有includeParams="all"
的<s:url>
标记和空的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屋!