springboot+MessageSource實現國際化


1、springboot自帶,不需要引入任何依賴

2、在resource下建立:i18n/messages.properties

3、在application.yml增加以下內容

spring:
    application:
        name: myapp
 messages: basename: i18n/messages encoding: UTF-8

 

4、在類中引入MessageResource

 

 5、獲取消息

String suffixMsg = messageSource.getMessage(“9001”,null, null);

6、messages.properties

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM