简单几步教你做你国际化网站

news/2024/5/8 16:36:45/文章来源:https://blog.csdn.net/m0_55337678/article/details/125773226
  • 什么是国际化?

国际化故名思意,就是可以做到一个国际化的标准,就是每个国家的人都可以看的懂你网站的内容,可以中英日韩文切换。

看下面的图,有中文或者英文可以选择你看的懂的语言:

  • 好了,介绍完毕,我们来看看怎么操作 

1.在Resource的下面建一个资源包比如我们要对登录界面就行国际化

 我们可以看到我们这里是中英文

 2.配置完资源包,然后再界面应用

应用前我们要再spring的配置文件下面指定资源位置

spring:
messages:basename: Internationalization.login

 3.创建地域解析器

public class MyLocalResolver implements LocaleResolver {@Overridepublic Locale resolveLocale(HttpServletRequest request) {String l = request.getParameter("lang");//获取默认的区域信息解析器Locale locale = Locale.getDefault();//根据请求中的参数重新构造区域信息对象if (StringUtils.hasText(l)) {String[] s = l.split("_");locale = new Locale(s[0], s[1]);}return locale;}@Overridepublic void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) {}
}

4.Bean注册

@Configuration
public class ApplicationConfig {@Beanpublic LocaleResolver localeResolver(){return new MyLocalResolver();}
}

5.Html页面

测试效果 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_785219.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

99designs荣获SmartCompany Awards最佳网站奖

A quick shout out to the guys who work at SitePoint’s sister company, 99designs.com, who last week took out the “Top Website Award” in the 2008 SmartCompany Awards. The awards honor the fastest growing and most innovative companies of Australia in 2008.…

帮助中心 开源_开源资金网站microPledge寻求帮助

帮助中心 开源In the open source world, “software bounties” are a familiar concept — money is raised for a developer to implement a new feature, write documentation, or create a new piece of software. Since it launched last August, Christchurch, New Zeal…

seo规范_使用Google的新规范元素改善SEO

seo规范Avoid duplicate content. Every good Search Engine Optimization expert will tell you that original content is the best way to succeed in your attempt to climb the slippery search engine slope. Copying content from elsewhere or syndicating the the sam…

python scrapy 实战简书网站保存数据到mysql

1:创建项目 2:创建爬虫 3:编写start.py文件用于运行爬虫程序 # -*- coding:utf-8 -*- #作者: baikai #创建时间: 2018/12/14 14:09 #文件: start.py #IDE: PyCharm from scrapy import cmdlinecmdline.execute("scrapy crawl js"…

Flask项目之手机端租房网站的实战开发(十)

说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/86488529 目录 一丶区县信息前端编写 二丶发布新房源后…

MVC4.0网站发布和部署到IIS7.0上的方法

最近在研究MVC4,使用vs2010,开发的站点在发布和部署到iis7上的过程中遇到了很多问题,现在将解决的过程记录下来,以便日后参考,整个过程主要以截图形式呈现 vs2010的安装和mvc4的安装不在本次记录之列,主要记…

抓取某一个网站整站的记录

2019独角兽企业重金招聘Python工程师标准>>> 经常由于某些原因我们需要爬取某一个网站或者直接复制某一个站点,到网上找了很多工具进行测试,试了很多各有各的问题,最终选择了Teleport Ultra,用起来效果很好&#xff1b…

防弹您的Drupal网站

“When you steal money or goods, somebody will notice it’s gone. When you steal information, most of the time no one will notice because the information is still in their possession.” – Kevin Mitnick, The Art of Deception, 2003.“当您窃取金钱或商品时&am…

Magento电子商务网站的SEO指南

Magento is only five years old but is already the most popular open-source eCommerce platform on the net, boasting a community of over 150,000 online retailers. Magento只有5岁,但已经是网络上最受欢迎的开源电子商务平台,拥有超过150,000个…

使用WordPress构建非博客网站

This post digs into how you can use WordPress to run a regular, non-blog website. 这篇文章深入探讨了如何使用WordPress来运行常规的非博客网站。 WordPress began as a blogging platform and has a long-established dominance in the world of blogging. No matter w…

2m带宽允许多少用户访问_您有多少用户需要可访问的网站?

2m带宽允许多少用户访问The Web Content Accessibility Guidelines (WCAG) came into existence in order to provide equal access and equal opportunity to people with disabilities. If the Web is accessible, many people with disabilities can communicate and intera…

谷歌深度神经网络_本周关注我们:轻松阅读,神经网络和Google召集不良网站

谷歌深度神经网络发展更好的体验 (Developing a Better Experience) With the wide variety of devices people use to browse the web today, steps are being taken to try and maintain peoples quality of experience. Google are now calling out pages that will not wor…

modern php_如何使用Modern.IE在本地测试您的网站

modern phpThis article was sponsored by Modern.IE. Thanks for supporting the sponsors that make SitePoint possible! 本文由Modern.IE赞助。 感谢您支持使SitePoint成为可能的赞助商! There’s no shortage of front end tools to help us test the qualit…

web应用程序和web网站_Web应用程序是未来

web应用程序和web网站Native mobile apps are a little weird, if you stop and think about them. 如果您停下来考虑一下,本机移动应用程序会有些奇怪。 The average mobile app weighs around 20MB, often requires an internet connection in order to be used …

joomla一键部署_如何在阿里云ECS上部署和托管Joomla网站

joomla一键部署This article was originally published on Alibaba Cloud. Thank you for supporting the partners who make SitePoint possible. 本文最初发表在阿里云上 。 感谢您支持使SitePoint成为可能的合作伙伴。 Joomla! is a free and open source content manageme…

seo策略_改善参与度指标的5种基本SEO策略

seo策略Every time someone types in a search query on Google, they’re given a list of results. 每当有人在Google上输入搜索查询时,就会得到一个结果列表。 The way in which those results are ordered is a highly complex algorithmic process that take…

wordpress环境安装_为什么暂存环境对于WordPress网站至关重要

wordpress环境安装This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 Have you …

什么是您网站的正确图像格式?

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible. 本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。 As of March 2017, images m…

seo服务端渲染_我应该向SEO服务收取多少费用?

seo服务端渲染Good SEO might be the very reason you’re reading this article. As its name implies, SEO is the process of optimizing a website or web page to maximize visibility in search engine results, and it is hugely important for any business that maint…

wordpress 邮件_将您的WordPress网站变成电子邮件营销机器

wordpress 邮件With over 35,000 plugins available, there are few things that you cannot do with WordPress. 有超过35,000个可用的插件,几乎没有WordPress无法做的事情。 For many site builders, the ultimate goal is to reach as many viewers as possible…