1.首先將idea的編碼轉換,預防亂碼
2.在resources檔案下建立i18n檔案,如圖所示
3.在properties中配置:
spring.messages.basename=i18n.login4.如果需要手動去切換國際話而不是跟隨遊覽器語言變化需要寫自己的localeresolver
**
* @auther: dell
* @date: 2020/3/11 09:39
* @description:國際化需要手動切換時需要
}
5.將自己定義的localeresolver例項化到容器中
springboot實現國際化
在spring中提供了乙個介面messagesource來實現國際化。springboot中已經對國際化做了自動配置,自動配置messagesourceautoconfiguration,接下來我們看一下該類。bean configurationproperties prefix spring.me...
Spring Boot國際化的實現
1.建立目錄及檔案 預設配置檔案login.properties login.username 使用者名稱 英語配置檔案login en us.properties login.username username 中文配置檔案login zh cn.properties login.username...
springboot國際化配置流程
在resource下面新增i18n資料夾,下面放置轉換的檔案字尾是有規則的,預設的messages.properties,英文 messages en us.properties,中文 messages zh cn.properties。比如 configuration public class i...