[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,做了大量的研究,对前后端交互 ...
随机推荐
- centos7 设置mongodb远程连接
/etc/mongod.conf 更改 bindIp: 127.0.0.1 为 bindIp: 0.0.0.0
- Spring源码解析(一)开篇
前言 Spring源码继承结构比较复杂,看过以后经常会忘记.因此,记录一下源码分析的过程,方便以后回顾.本次分析的Spring源码版本为3.2.15. 另外,一提Spring就是IOC.DI等等,我们 ...
- NAND flash学习所获----(Zac)
Nand Falsh外围电路:peripheral circuit 1.Nand flash里至少有2个state Machine(controller),即2个主控. 一个主控:负责处理前端事情. ...
- 《Oracle RAC性能优化》
一 RAC环境 RAC架构,2节点信息 节点1 SQL> show parameter instance NAME TYPE ...
- Using RUNDLL32.exe to call a function within a dll
Using RUNDLL32.exe to call a function within a dll Rundll32 is a utility included with Window ...
- 12.MySQL必知必会之分组数据
本文将介绍如何分组数据,以便能汇总表内容的子集,这涉及两个新SELECT语句子句,分别是 GROUP BY 子句和HAVING子句. 1.1 创建分组 分组是在SELECT语句的GROUP BY子句中 ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A Is it rated?
地址:http://codeforces.com/contest/807/problem/C 题目: C. Success Rate time limit per test 2 seconds mem ...
- sqlite常用的命令-增删改查
一.查看版本信息: #sqlite3 -version 二.sqlite3常用命令 1.当前目录下建立或打开test.db数据库文件,并进入sqlite命令终端,以sqlite>前缀标识: 2. ...
- GZFramework错误(升级修改)日志
sqlserver下事务中处理出现为初始化selectcommand的connection属性修改CommandDataBase中的PrepareCommand方法
- [原创]css中a标签去掉锚点文本下划线
我对博客的认识是:记录问题,解决问题,分享知识.如果有轮子,我不需要造轮子. 1.问题解决方式: 设置属性:text-decoration:none; 2.更多属性参数参考 text-decorati ...