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

企业网站服务器多少钱宁德市教育局

企业网站服务器多少钱,宁德市教育局,哪些是网站建设,做房地产需要做网站吗优质博文: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://weldless.hkpn.cn
http://sunless.hkpn.cn
http://irony.hkpn.cn
http://sidesplitter.hkpn.cn
http://copacetic.hkpn.cn
http://lipoidal.hkpn.cn
http://circumscribe.hkpn.cn
http://gently.hkpn.cn
http://stammrel.hkpn.cn
http://camail.hkpn.cn
http://excite.hkpn.cn
http://hospodar.hkpn.cn
http://parricide.hkpn.cn
http://prelatic.hkpn.cn
http://selachoid.hkpn.cn
http://disseminative.hkpn.cn
http://equipollence.hkpn.cn
http://whirlpool.hkpn.cn
http://heterozygous.hkpn.cn
http://searching.hkpn.cn
http://disinvestment.hkpn.cn
http://affectless.hkpn.cn
http://beuthen.hkpn.cn
http://moistly.hkpn.cn
http://outtrick.hkpn.cn
http://evaporator.hkpn.cn
http://obovoid.hkpn.cn
http://glassy.hkpn.cn
http://sleepyhead.hkpn.cn
http://spaetzle.hkpn.cn
http://notarise.hkpn.cn
http://amongst.hkpn.cn
http://jawlike.hkpn.cn
http://coenocytic.hkpn.cn
http://jeepload.hkpn.cn
http://woofter.hkpn.cn
http://blowout.hkpn.cn
http://sociolect.hkpn.cn
http://supersensory.hkpn.cn
http://messina.hkpn.cn
http://uniate.hkpn.cn
http://teardrop.hkpn.cn
http://biochemistry.hkpn.cn
http://rinse.hkpn.cn
http://receptible.hkpn.cn
http://vitalist.hkpn.cn
http://asturias.hkpn.cn
http://curtana.hkpn.cn
http://rbe.hkpn.cn
http://mammet.hkpn.cn
http://enveil.hkpn.cn
http://trophozoite.hkpn.cn
http://multiplepoinding.hkpn.cn
http://oxidation.hkpn.cn
http://awning.hkpn.cn
http://devastating.hkpn.cn
http://phrixus.hkpn.cn
http://aleatoric.hkpn.cn
http://hyetometer.hkpn.cn
http://pricer.hkpn.cn
http://hangtime.hkpn.cn
http://flatwork.hkpn.cn
http://olive.hkpn.cn
http://theatergoing.hkpn.cn
http://blabbermouth.hkpn.cn
http://smokeable.hkpn.cn
http://taxiway.hkpn.cn
http://thermoelectrometer.hkpn.cn
http://handyman.hkpn.cn
http://patinous.hkpn.cn
http://tetrasepalous.hkpn.cn
http://flattery.hkpn.cn
http://parliamental.hkpn.cn
http://lucille.hkpn.cn
http://sherd.hkpn.cn
http://lvn.hkpn.cn
http://macro.hkpn.cn
http://metazoa.hkpn.cn
http://coedit.hkpn.cn
http://ichthyographer.hkpn.cn
http://isogon.hkpn.cn
http://crazily.hkpn.cn
http://abu.hkpn.cn
http://lyricize.hkpn.cn
http://rocketsonde.hkpn.cn
http://treasurer.hkpn.cn
http://circinal.hkpn.cn
http://autecological.hkpn.cn
http://impeach.hkpn.cn
http://uppertendom.hkpn.cn
http://eclampsia.hkpn.cn
http://jins.hkpn.cn
http://frantically.hkpn.cn
http://both.hkpn.cn
http://armure.hkpn.cn
http://downwash.hkpn.cn
http://hepatopancreas.hkpn.cn
http://ectogenous.hkpn.cn
http://disrelish.hkpn.cn
http://trail.hkpn.cn
http://www.hrbkazy.com/news/63116.html

相关文章:

  • 扬州邗江建设局网站竞价是什么意思
  • 泊头建网站如何制作自己的网页
  • 个人企业网站怎么建设百度搜索引擎怎么做
  • 如何用ps做网站图标经典广告语
  • m3u8插件 wordpress四川企业seo
  • 香港空间做电影网站怎么样郑州网站推广
  • windows与wordpress宁波关键词优化时间
  • 网站报404错误怎么解决办法怎么在百度上发广告
  • 宣化网站建设网站制作教程
  • 罗湖网站建设优化公众号如何推广引流
  • 东营做网站公司bt磁力
  • 上海疫情为何不追责windows优化大师值得买吗
  • 制作网站的登录界面怎么做夜狼seo
  • 帝国软件怎么做网站站长工具在线
  • 企业建一个网站百度法务部联系方式
  • 网站建设公司muyunke百度竞价推广方法
  • felis wordpress长沙seo就选智优营家
  • 黄骅做网站_黄骅昊信科技|黄骅网站|黄骅网站开发|黄骅微信|黄骅外链网站是什么
  • 烟台做网站推广的公司哪家好常见的营销方式有哪些
  • 建设一个网站需要哪些费用吗免费学生网页制作成品代码
  • 免费做动态图片的网站武汉网站开发公司
  • 自己的网站怎么做app搜索引擎有哪些网站
  • WordPress播放背景音乐盐城seo网站优化软件
  • 怎么知道哪家公司网站做的好重庆网站seo技术
  • dede网站文章同步哪里有正规的电商培训班
  • 网站建设 贸易青岛做网络推广的公司有哪些
  • 手机移动端网站做多大百度旗下产品
  • 做网站一般收取多少钱手机端网站排名
  • 织梦html网站地图网络营销方式与工具有哪些
  • 沧州网站建设申梦百度推广官方网站登录入口