i18n(其来源是英文单词 internationalization的首末字符i和n,18为中间的字符数)是“国际化”的简称。在资讯领域,国际化(i18n)指让产品(出版物,软件,硬件等)无需做大的改变就能够适应不同的语言和地区的需要。
用上次布属JSR303的为例,继续配置i18n
JSR303数据有效性验证https://mp.csdn.net/mp_blog/creation/editor/127427393
- 在Springmvc中配置国际化资源文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"> <!-- 必须要使用以下配置才能生效 --> <mvc:annotation-driven /> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="i18n"></property> </bean> </beans>
-
在src/main/resources中生成一个i18n.properties文件
NotEmpty.user.name \u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A typeMismatch.user.birthday=\u8BF7\u4F7F\u7528\u6B63\u786E\u7684\u65E5\u671F\u683C\u5F0F\uFF0C\u59822009-01-01 typeMismatch.user.height=\u8BF7\u8F93\u5165\u6570\u5B57
注:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/71217.html