struts2如何触底实现国际化
来源:互联网 发布:怎样做淘宝返利群 编辑:程序博客网 时间:2024/05/29 17:14
1、使用i18n对应的拦截器:
从源代码中可以得知,我们如果传递了一个参数的话,语言就被存到了session中,传递的参数在拦截器中有说明;
如果没有的话,就去找默认的语言了,默认语言在ValueStack值栈中存储,
源代码:
public class I18nInterceptor extends AbstractInterceptor {
protected static final Logger LOG = LoggerFactory.getLogger(I18nInterceptor.class);
//session中存储的Locale对象的key
public static final String DEFAULT_SESSION_ATTRIBUTE = "WW_TRANS_I18N_LOCALE";
//把请求的代码换成是这个名称,并传递相应的语言就可以实现语言的切换了
//传递的参数,即语言的类型
public static final String DEFAULT_PARAMETER = "request_locale";
public static final String DEFAULT_REQUESTONLY_PARAMETER = "request_only_locale";
案例如下:
<a href="localAction?request_locale=zh_CN"><s:text name="chinese"/></a>
<a href="localAction?request_locale=en_US"><s:text name="english"/></a>
配置一个默认的action就可以了:
<action name="localAction" >
<result>/index.jsp</result>
</action>
- struts2如何触底实现国际化
- struts2实现国际化
- struts2实现国际化
- struts2实现国际化
- struts2国际化实现过程
- Struts2 的国际化实现
- Struts2 的国际化实现
- Struts2 的国际化实现
- Struts2 的国际化实现
- Struts2 的国际化实现
- Struts2实现国际化
- Struts2的国际化实现
- Struts2 的国际化实现
- struts2实现国际化
- Struts2 本地化/国际化实现
- struts2实现国际化
- Struts2 的国际化实现
- struts2 用户自定义实现国际化
- iOS UIScrollView无限循环滚动和手动滚动
- TK1安装Caffe
- js实现通过类名获取元素(通用版)
- poj2823 Sliding Window
- Scrapy抓取在不同级别Request之间传递参数
- struts2如何触底实现国际化
- Android 怎么动态设置shape定义的控件的背景色
- 【并查集】Mushroom的区间
- ListView之ViewHolder类封装
- CentOS 安装配置JDK与Tomcat支持jsp文件解析
- 【十月总结】2016.10.31
- hdu 1709 普通母函数
- ocos2d-JS 屏幕适配相关内容
- Hive调优(语法与参数层面优化)