[Spring]Spring Mvc实现国际化/多语言
1.添加多语言文件*.properties

F64_en_EN.properties详情如下:
F60_G00_M100=Please select data. F60_G00_M101=Are you sure you want to delete? F60_G00_M102=The data is changed. Do you want to save it ?
2、配置springMVC配置文件
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list> <!--后续开发中需要国际化的模块添加到这里即可-->
<value>i18n.Example</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
<property name="useCodeAsDefaultMessage" value="true" />
</bean>
<!--设置cookie解释器分析设置的国际化多语言 -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieMaxAge" value="315360000" />
<property name="defaultLocale" value="en_EN" />
<property name="cookieName" value="Language"> </property>
</bean>
3.在登录成功后修改运行环境的语言
// 根据选择的语言种类设置配置文件中的localeResolver的内容
if ("EN".equals(logonUser.getLanguage())) {
Locale localeEN = new Locale("en", "EN");
localeResolver.setLocale(request, response, localeEN);
} else if ("JA".equals(logonUser.getLanguage())) {
Locale localeJP = new Locale("ja", "JP");
localeResolver.setLocale(request, response, localeJP);
} else {
Locale localeEN = new Locale("en", "EN");
localeResolver.setLocale(request, response, localeEN);
}
4.定义取得文言内容的方法
protected String getMessage(String code,Object... params){
return messageSource.getMessage(code, params, LocaleContextHolder.getLocale());
}
5.取得文言内容
String title = getMessage("RF64_L001");
[Spring]Spring Mvc实现国际化/多语言的更多相关文章
- 使用Spring MVC 实现 国际化
使用Spring MVC 实现 国际化 博客分类: Spring 1. 版本 Spring 3.1 2. 配置 LocaleResolver LocaleResolver 是指 ...
- Java Web 学习(7) —— Spring MVC 之国际化
Spring MVC 之国际化 i18n 与 l10n internationalization:国际化,以 i 开头,以 n 结尾,中间 18 个字母,简称 i18n. localization:本 ...
- Spring+Spring MVC+MyBatis
Spring+Spring MVC+MyBatis 目录 一.新建一个基于Maven的Web项目 二.创建数据库与表 三.添加依赖包 四.新建POJO实体层 五.新建MyBatis SQL映射层 六. ...
- Spring 4 MVC+Hibernate 4+MySQL+Maven使用注解集成实例
Spring 4 MVC+Hibernate 4+MySQL+Maven使用注解集成实例 转自:通过注解的方式集成Spring 4 MVC+Hibernate 4+MySQL+Maven,开发项目样例 ...
- 基于Spring + Spring MVC + Mybatis + shiro 高性能web构建
一直想写这篇文章,前段时间 痴迷于JavaScript.NodeJs.AngularJS,做了大量的研究,对前后端交互有了更深层次的认识. 今天抽个时间写这篇文章,我有预感,这将是一篇很详细的文章,详 ...
- 1.Spring Web MVC有什么
Spring Web MVC使用了MVC架构模式的思想,将web层进行职责解耦. 同样也是基于请求驱动的,也就是使用请求-响应模型.它主要包含如下组件: DispatcherServlet :前端控制 ...
- [转]基于Spring + Spring MVC + Mybatis 高性能web构建
http://blog.csdn.net/zoutongyuan/article/details/41379851/ 一直想写这篇文章,前段时间 痴迷于JavaScript.NodeJs.Angula ...
- Spring - Sring MVC入门
2.1.Spring Web MVC是什么 Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职 ...
- 基于Spring + Spring MVC + Mybatis 高性能web构建
基于Spring + Spring MVC + Mybatis 高性能web构建 一直想写这篇文章,前段时间 痴迷于JavaScript.NodeJs.AngularJs,做了大量的研究,对前后端交互 ...
随机推荐
- weblogic中eclipse远程调试
1. weblogic 配置文件修改 修改文件: weblogic/weblogic103/user_projects/domains/xxxx/bin/setDomainEnv.sh(windows ...
- Java基础—输入输出流
流的概念 在Java中,流是从源到目的地的字节的有序序列.Java中有两种基本的流——输入流(InputStream)和输出流(OutputStream). 根据流相对于程序的另一个端点的不同,分为节 ...
- 六、Mosquitto 高级应用之SSL/TLS
mosquitto提供SSL支持加密的网络连接和身份验证.本章节讲述次功能的实现. 在此之前需要一些准备工作. 准本工作: 一台 Linux 服务器. 安装好 openssl (不会明白怎么安装 op ...
- xlrd xlwt操作
简介 xlrd,xlwt和xlutils是用Python处理Excel文档(*.xls)的高效率工具.其中,xlrd只能读取xls,xlwt只能新建xls(不可以修改),xlutils能将xlrd.B ...
- Android 按钮 弹出对话框
ackage com.example.helloworld; import android.os.Bundle;import android.app.Activity;import android.a ...
- 64. Minimum Path Sum(最小走棋盘 动态规划)
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- 2018秦皇岛ccpc-camp Steins;Gate (原根+FFT)
因为给定的模数P保证是素数,所以P一定有原根. 根据原根的性质,若\(g\)是\(P\)的原根,则\(g^k\)能够生成\([1,P-1]\)中所有的数,这样的k一共有P-2个. 则\(a_i*a_j ...
- List泛型集合转DataTable
自存,此方法可以防止出现DataSet不支持System.Nullable的错误 public static DataTable ToDataTable<T>(IEnumerable< ...
- Linux使用free命令查看实际内存占用
转自:http://www.cnblogs.com/pengdonglin137/p/3315124.html Linux下在终端环境下可以使用free命令看到系统实际使用内存的情况,一般用free ...
- OpenStack之Nova模块
Nova简介 nova和swift是openstack最早的两个组件,nova分为控制节点和计算节点,计算节点通过nova computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,no ...