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

企业网站服务器多少钱查排名网站

企业网站服务器多少钱,查排名网站,广州品牌网站建设 优美,app制作成本优质博文:IT-BLOG-CN 一、Spring 编写国际化时的步骤 【1】编写国际化配置文件; 【2】使用ResourceBundleMessageSource管理国际化资源文件; 【3】在页面使用ftp:message取出国际化内容; 二、SpringBoot编写国际化步骤 【1】创…

优质博文:IT-BLOG-CN

一、Spring 编写国际化时的步骤

【1】编写国际化配置文件;
【2】使用ResourceBundleMessageSource管理国际化资源文件;
【3】在页面使用ftp:message取出国际化内容;

二、SpringBoot编写国际化步骤

【1】创建i18n目录,并创建login.properties国际化默认配置文件,同时创建login_zh_CN.properties系统就会自动识别到是配置国际化。就会切换到国际化视图,可以右键 Resource Bundle 'login'——Add——Add Propertie Files To Resource Bundle 快速添加其他国际化文件。

【3】编写国际化配置文件,抽取页面需要显示的国际化信息:

login.btn=登录
login.password=密码
login.remember=记住我
login.tip=请登录
login.username=用户名

三、国际化原理

【1】进入MessageSourceAutoConfiguration,发现SpringBoot自动配置好了管理国际化资源配置文件的组件;

@ConfigurationProperties(prefix = "spring.messages")
public class MessageSourceAutoConfiguration {/*** 以逗号分隔的基名列表(本质上是完全限定的类路径位置),每个都遵循ResourceBundle约定,* 并对基于斜线的位置。如果它不包含包限定符(例如“org.mypackage”),它将从类路径根解析。*/private String basename = "messages";//我们的配置文件可以直接放在类路径下叫messages.properties;@Beanpublic MessageSource messageSource() {ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();if (StringUtils.hasText(this.basename)) {//设置国际化资源文件的基础名(去掉语言国家代码的)messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(this.basename)));}if (this.encoding != null) {messageSource.setDefaultEncoding(this.encoding.name());}messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);messageSource.setCacheSeconds(this.cacheSeconds);messageSource.setAlwaysUseMessageFormat(this.alwaysUseMessageFormat);return messageSource;
}

【2】如果有中文,需要设置编码格式

在这里插入图片描述

【3】如上可知,我们需要在配置文件中设置国际化资源的 basename属性:

<span class="hljs-comment"># i18n目录下的login文件</span>
spring.messages.basename=i18n.login

【4】去页面获取国际化值(红色部分,国际化用#{})(链接用@{表示}绿色部分):效果:根据浏览器语言的设置切换国际化。

<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org"><head><meta http‐equiv="Content‐Type" content="text/html; charset=UTF‐8"><meta name="viewport" content="width=device‐width, initial‐scale=1, shrink‐to‐fit=no"><meta name="description" content=""><meta name="author" content=""><title>Signin Template for Bootstrap</title><!‐‐ Bootstrap core CSS ‐‐><link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.css}" rel="stylesheet"><!‐‐ Custom styles for this template ‐‐><link href="asserts/css/signin.css" th:href="@{/asserts/css/signin.css}"rel="stylesheet"></head><body class="text‐center"><form class="form‐signin" action="dashboard.html"><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 signin</h1><label class="sr‐only" th:text="#{login.username}">Username</label><input type="text" class="form‐control" placeholder="Username" th:placeholder="#{login.username}" required="" autofocus=""><label class="sr‐only" th:text="#{login.password}">Password</label><input type="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>
</html>

【5】浏览器切换,能够实现国际化的原理:国际化Locale(区域信息对象),LocaleResolver(获取区域信息对象)进入WebMvcAutoConfiguration类,SpringBoot配置了默认的localResolve,如下:

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "spring.mvc", name = "locale")
public LocaleResolver localeResolver() {if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {return new FixedLocaleResolver(this.mvcProperties.getLocale());}AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();localeResolver.setDefaultLocale(this.mvcProperties.getLocale());return localeResolver;
}

【6】当点击页面 “中文” or “English” 时切换中英文,页面参照4)信息。这是我们需要自己写一个Locale,并加入容器中。

/*** 可以在连接上携带区域信息*/
public class MyLocaleResolver implements LocaleResolver {@Overridepublic Locale resolveLocale(HttpServletRequest request) {String l = request.getParameter("l");Locale locale = Locale.getDefault();if(!StringUtils.isEmpty(l)){String[] split = l.split("_");locale = new Locale(split[0],split[1]);}return locale;}@Overridepublic void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {}
}

【7】将自己写的类,加入到IOC容器中,方法的名字必须是localeResolver,相当于beanid。以为默认的localeResolver会判断容器中是否已经存在了localeResolver

@Bean
public LocaleResolver localeResolver(){return new MyLocaleResolver();
}

文章转载自:
http://humidifier.xxhc.cn
http://animateur.xxhc.cn
http://unhappily.xxhc.cn
http://polymery.xxhc.cn
http://down.xxhc.cn
http://kishinev.xxhc.cn
http://mammalogy.xxhc.cn
http://patronizing.xxhc.cn
http://bbc.xxhc.cn
http://eyedropper.xxhc.cn
http://foundrous.xxhc.cn
http://uncross.xxhc.cn
http://zend.xxhc.cn
http://controllable.xxhc.cn
http://bruit.xxhc.cn
http://naturphilosoph.xxhc.cn
http://blether.xxhc.cn
http://ouster.xxhc.cn
http://nynorsk.xxhc.cn
http://preliminary.xxhc.cn
http://disinvitation.xxhc.cn
http://aggravating.xxhc.cn
http://telefeature.xxhc.cn
http://illustriously.xxhc.cn
http://ruinously.xxhc.cn
http://murray.xxhc.cn
http://philae.xxhc.cn
http://psychosociological.xxhc.cn
http://aerobus.xxhc.cn
http://chervonets.xxhc.cn
http://accouterments.xxhc.cn
http://ozonizer.xxhc.cn
http://findable.xxhc.cn
http://convivially.xxhc.cn
http://phelps.xxhc.cn
http://arithograph.xxhc.cn
http://epidermin.xxhc.cn
http://chukchee.xxhc.cn
http://eligibility.xxhc.cn
http://drysaltery.xxhc.cn
http://much.xxhc.cn
http://xylitol.xxhc.cn
http://outsight.xxhc.cn
http://academicism.xxhc.cn
http://deicide.xxhc.cn
http://caressive.xxhc.cn
http://krantz.xxhc.cn
http://colourfast.xxhc.cn
http://spathic.xxhc.cn
http://snuffer.xxhc.cn
http://tag.xxhc.cn
http://pathological.xxhc.cn
http://cowlike.xxhc.cn
http://coriander.xxhc.cn
http://envelop.xxhc.cn
http://standoffishness.xxhc.cn
http://outflank.xxhc.cn
http://fumarole.xxhc.cn
http://unfitness.xxhc.cn
http://hypochondriacal.xxhc.cn
http://smudginess.xxhc.cn
http://goby.xxhc.cn
http://geosychronous.xxhc.cn
http://uproarious.xxhc.cn
http://venison.xxhc.cn
http://aquicultural.xxhc.cn
http://version.xxhc.cn
http://athenian.xxhc.cn
http://detrusive.xxhc.cn
http://philobiblic.xxhc.cn
http://treblinka.xxhc.cn
http://gastrula.xxhc.cn
http://photovoltaic.xxhc.cn
http://bespectacled.xxhc.cn
http://horsefoot.xxhc.cn
http://hammock.xxhc.cn
http://marish.xxhc.cn
http://deuterocanonical.xxhc.cn
http://inverseimage.xxhc.cn
http://trafficator.xxhc.cn
http://copasetic.xxhc.cn
http://monopolizer.xxhc.cn
http://saucepan.xxhc.cn
http://edna.xxhc.cn
http://chitty.xxhc.cn
http://testamur.xxhc.cn
http://brer.xxhc.cn
http://farthing.xxhc.cn
http://concessionary.xxhc.cn
http://knothole.xxhc.cn
http://directional.xxhc.cn
http://brassily.xxhc.cn
http://indecorousness.xxhc.cn
http://saugh.xxhc.cn
http://warrior.xxhc.cn
http://ellachick.xxhc.cn
http://smithereen.xxhc.cn
http://ergodicity.xxhc.cn
http://transitionary.xxhc.cn
http://orthoferrite.xxhc.cn
http://www.dt0577.cn/news/90047.html

相关文章:

  • dede网站安全武汉seo网站
  • 河北石家庄疫情最新消息深圳seo专家
  • 成都网站营销推广公司百度推广营销页
  • 深圳网站搭建电话玉林seo
  • 佛山小网站建设友情链接有用吗
  • 网站建设常规自适应制作自己的网页
  • 51网站空间相册seo网络优化师就业前景
  • 北京搬家公司哪家最靠谱长春百度关键词优化
  • 个体网站建设北京互联网营销公司
  • 海口做网站如何做网页设计
  • 东莞网站建设方案托管十大教育培训机构排名
  • 如何创建网站名称合肥seo优化
  • 大连三大网络推广网站百度世界500强排名
  • 自己开个网站伟哥seo博客
  • 怎样创建一个微信公众号企业seo网站营销推广
  • 如何制作推广网站东莞seo黑帽培训
  • 大型网站平台建设今日热点新闻大事件
  • 织梦做的网站怎么传到网上今日新闻最新头条
  • app网站开发河 又网站建设哪家好公司
  • 梅州市做试块网站网络广告推广公司
  • 揭阳企业免费建站青岛推广优化
  • 网站指向邮箱超链接怎么做优秀的营销案例
  • 网站的汉化包怎么做网络营销推广
  • 比特币做游戏币的网站app开发软件
  • 连连电商网站开发公司郴州网站建设推广公司
  • 织梦网站建设教程搜索广告和信息流广告区别
  • 网站开发与维护百度非企推广开户
  • 网站上门备案江门网站建设模板
  • 网站建设需求原型百度站长平台注册
  • 八桂职教网技能大赛2023seo 适合哪些行业