当前位置: 首页 > news >正文

网站源代码下载工具什么关键词可以搜到那种

网站源代码下载工具,什么关键词可以搜到那种,在线爱情动做网站,wordpress 最新文章国际化实现步骤 Spring Boot 3 提供了强大的国际化支持#xff0c;使得应用程序可以根据用户的语言和区域偏好适配不同的语言和地区需求。 添加国际化资源文件#xff1a; 国际化资源文件通常放在 src/main/resources 目录下#xff0c;并按照不同的语言和地区命名#xf…国际化实现步骤 Spring Boot 3 提供了强大的国际化支持使得应用程序可以根据用户的语言和区域偏好适配不同的语言和地区需求。 添加国际化资源文件 国际化资源文件通常放在 src/main/resources 目录下并按照不同的语言和地区命名例如 messages.properties默认语言如英文messages_zh_CN.properties中文简体messages_fr.properties法语 配置 MessageSource Bean 可以通过在 application.properties 或 application.yml 中进行简单配置来加载国际化资源文件 spring:messages:basename: messagesencoding: UTF-8 或者在配置类中定义 MessageSource Bean Configuration public class MessageConfig {Beanpublic MessageSource messageSource() {ReloadableResourceBundleMessageSource messageSource new ReloadableResourceBundleMessageSource();messageSource.setBasename(classpath:messages);messageSource.setDefaultEncoding(UTF-8);return messageSource;} } 使用国际化资源 在代码中可以通过 MessageSource 来获取国际化消息。例如在控制器中根据请求参数确定语言环境并获取对应的消息。 模板中的国际化 如果使用 Thymeleaf 作为模板引擎可以在模板中直接使用国际化消息。需要确保在 application.properties 中启用了国际化支持并且在模板中使用 #{} 表达式引用消息键。 自动检测客户端语言 Spring Boot 提供了 LocaleResolver 来自动检测和设置客户端的语言环境。可以使用 AcceptHeaderLocaleResolver 或自定义的 LocaleResolver。 缓存本地语言设置 若要将本地语言设置缓存可以在自己的配置类中增加 LocaleChangeInterceptor 拦截器和实现 LocaleResolver 方法。比如使用 CookieLocaleResolver 将语言设置存储在 Cookie 中。 与 Spring Security 结合 在使用 Spring Security 时可以通过在资源文件中添加相应的消息并在 Spring Security 配置中使用这些消息来实现登录页面和错误信息的多语言支持。 示例 配置国际化yaml spring:messages:encoding: UTF-8basename: i18n/messagesprofiles:active: zh_CN #-Dspring.profiles.activeen_US 英文 server:port: 8000 spring:jackson:date-format: MM-dd-yyyy中文 spring:jackson:date-format: yyyy-MM-dd server:port: 8000 国际化配置 package com.cokerlk.language;import com.cokerlk.language.service.EnUSProductService; import com.cokerlk.language.service.IProductService; import com.cokerlk.language.service.ZhCNProductService; import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile;Configuration Data public class I18NConfiguration {Value(${spring.profiles.active})private String locale;Profile(zh_CN)Beanpublic IProductService zhCNBussService(){return new ZhCNProductService();}Profile(en_US)Beanpublic IProductService enUSBussService(){return new EnUSProductService();} }产品接口 package com.cokerlk.language.service;import java.util.Map;public interface IProductService {MapString,String getProduct(); }中文产品 package com.cokerlk.language.service;import com.cokerlk.language.I18NConfiguration; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.context.MessageSource;import java.util.Date; import java.util.HashMap; import java.util.Locale; import java.util.Map;Slf4j public class ZhCNProductService implements IProductService {ResourceI18NConfiguration i18NConfiguration;ResourceMessageSource messageSource;Overridepublic Map getProduct() {log.info(中文);Map result new HashMap();result.put(create-date, new Date());result.put(text, messageSource.getMessage(product_name, null, Locale.of(i18NConfiguration.getLocale())));return result;} }英文产品 package com.cokerlk.language.service;import com.cokerlk.language.I18NConfiguration; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.context.MessageSource;import java.util.Date; import java.util.HashMap; import java.util.Locale; import java.util.Map;Slf4j public class EnUSProductService implements IProductService {ResourceI18NConfiguration i18NConfiguration;ResourceMessageSource messageSource;Overridepublic MapString,String getProduct() {log.info(英文);Map result new HashMap();result.put(create-date, new Date());result.put(text, messageSource.getMessage(product_name, null, Locale.of(i18NConfiguration.getLocale())));return result;} }message配置 #messages.properties product_namehuawei mate 70 #messages_en_US.properties product_nameHua wei mate 70 #messages_zh_CN.properties product_name华为mate70测试结果
http://www.hkea.cn/news/14521812/

相关文章:

  • 新网站建设的工作各大网站流量排名
  • 手机网站导航栏特效网站排名突然下降解决
  • 蜂蜜做的好网站或案例沈阳新民网站建设
  • 如何制作家具网站网站建设策划书 范文
  • 四川城乡建设网网站昆明优化广告公司
  • 建设网站的价格是多少钱郑州 发布会
  • 购物网站建设课程设计网站开发发送短信
  • 百度推广帮做网站建设厅网站174号文
  • 江苏省建设工人考勤网站在线qq登录无需下载
  • 平顶山北京网站建设自己怎么做网站购买空间
  • 电子商务网站的后台管理系统关键词排名优化公司成都
  • 上海网站建设规划嘉兴网站建设咨询
  • 福田做网站价格网站建设公司公司我我提供一个平台
  • 国际贸易网站有哪些美丽乡村 网站建设
  • 怎么使用wordpress建站wordpress做微信登录页面模板
  • 手机网站开发session邯山手机网站建设
  • 企业网站php模板eclipse怎么做网页
  • 网站建设网站软件有哪些方面设计师互联网
  • 网站设计项目海南网址
  • 动态asp.net网站开发植物染企业解决方案
  • 广州模板网站建设wordpress怎么加栏目
  • 保山市网站建设wordpress开发商
  • 别人恶意点击我们竞价网站中国建设银行舟山分行网站
  • 中企高呈网站建设报考项目经理证需要什么条件
  • 建材 网站 模板洛阳网站建设启辰网络
  • 平度网站建设ld4wordpress主题安装目录
  • 台州网站制作自己做烘焙的网站
  • 小学校园门户网站建设方案php网站开发平台
  • 减肥网站源码城乡建设杂志网站
  • 自己建网站怎么赚钱wordpress地址无法更改