Spring国际化配置。

1,配置ResourceBundleMessageSource。

    @Bean
    public ResourceBundleMessageSource messageSource(){
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setDefaultEncoding("UTF-8");
        messageSource.setBasenames("i18n/messages");
        messageSource.setCacheSeconds(10);
        return messageSource;
}```
```java
      
          
          
          
  
    ```

####2,配置文件路径以及创建。
>创建Resource Bundle
![image.png](http://upload-images.jianshu.io/upload_images/5148056-3674f9e2108a789c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

>资源路径:
Spring框架下
![image.png](http://upload-images.jianshu.io/upload_images/5148056-653f7643f613d172.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
SpringBoot框架下
![image.png](http://upload-images.jianshu.io/upload_images/5148056-11e64556e45810d6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![image.png](http://upload-images.jianshu.io/upload_images/5148056-de4b451791a13143.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

####3,前端调用
><%@ taglib prefix="sp" uri="http://www.springframework.org/tags" %>
####4,浏览器设置 >拖动首选项语言。 ![image.png](http://upload-images.jianshu.io/upload_images/5148056-65a2f9515d2c90c1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Spring国际化配置。)