Spring boot国际化
国际化
根据浏览器,语言设置的信息
自动切换国际化支持
Spring MVC实现过程
1、编写国际化配置文件
2、使用ResourceBundleMessageSource管理国际化资源文件
3、在页面使用fmt:message取出国际化内容
Spring boot实现过程
1、编写国际化配置文件
抽取页面需要显示的国际化消息
Login,默认配置
Login_en_US,英文配置
Login_zh_CN,中文配置
Resource Bundle
直接编辑,每个字段的值
2、自动配置
SpringBoot自动配置好了
管理国际化资源文件的组件
MessageSourceAutoConfiguration
自定义的配置文件
可以直接放在类路径下叫messages.properties
这样,可以不用做任何的配置,直接使用国际化功能
指定配置文件
messageSource
setBasenames
设置国际化资源文件的基础名
基础名,表示去掉语言国家代码的
3、去页面获取国际化的值
#{ }
,获取国际化信息
th:text,是标签体里面的内容
Input是一个字节数的,没有标签体
可以使用行内写法
<input type="checkbox" value="remember-me"/> [[#{login.remember}]]
<body class="text-center"><form class="form-signin" action="dashboard.html" th:action="@{/user/login}" method="post"><img class="mb-4" th:src="@{/asserts/img/bootstrap-solid.svg}" src="asserts/img/bootstrap-solid.svg" alt="" width="72" height="72"><h1 class="h3 mb-3 font-weight-normal" th:text="#{login.tip}">Please sign in</h1><!--判断--><p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p><label class="sr-only" th:text="#{login.username}">Username</label><input type="text" name="username" class="form-control" placeholder="Username" th:placeholder="#{login.username}" required="" autofocus=""><label class="sr-only" th:text="#{login.password}">Password</label><input type="password" name="password" class="form-control" placeholder="Password" th:placeholder="#{login.password}" required=""><div class="checkbox mb-3"><label><input type="checkbox" value="remember-me"/> [[#{login.remember}]]</label></div><button class="btn btn-lg btn-primary btn-block" type="submit" th:text="#{login.btn}">Sign in</button><p class="mt-5 mb-3 text-muted">© 2017-2018</p><a class="btn btn-sm" th:href="@{/index.html(l='zh_CN')}">中文</a><a class="btn btn-sm" th:href="@{/index.html(l='en_US')}">English</a></form>
</body>
Spring boot国际化相关推荐
- Spring Boot国际化支持
文章目录 添加Maven支持 LocaleResolver LocaleChangeInterceptor 定义Message Sources Controller文件 html文件 运行应用程序 S ...
- 玩转spring boot——国际化
前言 在项目开发中,可能遇到国际化的问题,而支持国际化却是一件很头疼的事.但spring boot给出了一个非常理想和方便的方案. 一.准备工作 pom.xml: <?xml version=& ...
- Spring Boot国际化(i18n)
国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式.它要求从产品中抽离所有地域语言,国家/地区和文化相关的元素.换言之,应用程序的功能和代码设计考虑在不 ...
- spring boot 国际化
国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式.它要求从产品中抽离所有地域语言,国家/地区和文化相关的元素.换言之,应用程序的功能和代码设计考虑在不 ...
- Spring boot国际化切换
国际化切换 根据浏览器,语言设置的信息 自动的切换国际化支持 也可以根据用户选择 来切换国际化支持 Locale,表示区域信息对象 LocaleResolver,用来获取区域信息对象 自动配置 Web ...
- Spring Boot——国际化
- Spring Boot Validation提示信息国际化配置
引言 之前介绍过Spring Boot Validation的使用及扩展,可参见:<SpringBoot Validation> 本文在此基础上重点讲解下Spring Boot Valid ...
- Spring boot实现国际化
Spring boot国际化支持 当我们web项目涉及到国外部署或者国外用户使用时,需要展示不同语言信息,所以就需要国际化支持,下面将讲解Springboot国际化支持操作 1. 修改Springbo ...
- (10)Spring Boot修改端口号【从零开始学Spring Boot】
Spring boot 默认端口是8080,如果想要进行更改的话,只需要修改applicatoin.properties文件,在配置文件中加入: server.port=9090 常用配置: #### ...
最新文章
- Xcode的SVN提示The request timed out.的解决方案
- 解决网站请求速度慢的一些方法
- 50个Android应用!Win11支持运行了
- python数据类型可变和不可变_python可变数据类型vs不可变数据类型
- 转帖:XHTML原型开发-用代码说话
- 驾校一点通电脑版客户端 v7.1 最新PC版
- usb万能驱动win7_win10改win7教程
- 推荐一个项目管理工具:TAPD
- js删除对象的某个属性
- java 查找英语单词相似度,用于单词匹配,法1
- 浙江大学的计算机考研难度,浙江大学部分专业考研难度分析
- 计算机科学与技术单身率,中国大陆男女比例揭晓!大学单身率专业十强来了
- 【CSS】选择器汇总
- xiunobbs 4 mysql_xiunobbs
- 一、注册功能怎么测试
- ThreadLocal一次性解决老大难问题
- c盘oracle文件夹,C盘的用户文件夹转移到其他分区
- asp.net response.write输出html,ASP.NET 动态输出Javascript 文本格式换行问题 [ASP.NET | C# | Response]...
- 计算机格式化什么意思,终极:计算机格式化是什么意思?
- The Church-Turing thesis
热门文章
- 如何adb shell进入ctia模式
- Java对象转换为Json对象
- (译+原)std::shared_ptr及std::unique_ptr使用数组
- 设置log缓存_带你搞明白什么是缓存穿透、缓存击穿、缓存雪崩
- 波卡链Substrate (7)Grandpa协议四“责任安全机制”
- C++ Primer 5th笔记(chap 17 标准库特殊设施)regex_replace
- Hyperledger Fabric 管道(2) 管道的操作
- 《研磨设计模式》chap14 迭代器模式(3) 举例
- C++ Primer 5th笔记(1)chapter 1
- TF-A代码阅读: 双系统切换时是如何保存寄存器的(cpu_context介绍)