SPRINGMVC Internationalization
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/9B/wKiom1S1KLqDRiDBAAGFNgq5aOU081.jpg "title=" Qq20150113221555.jpg "alt=" Wkiom1s1klqdridbaagfngq5aou081.jpg "/>
The resource file. Use FMT tags to introduce jstl's two jar packages in advance.
I18n.properties content is as follows
I18n.username=usernamei18n.password=password
I18n_zh_cn.properties content is as follows
i18n.username=\u7528\u6237\u540di18n.password=\u5bc6\u7801
I18n_en_us.properties content is as follows
I18n.username=usernamei18n.password=password
In the spring configuration file, you need to include the following configuration
<!--resource file binder--><bean id= "Messagesource" class= " Org.springframework.context.support.ReloadableResourceBundleMessageSource "><property name=" Basenames "> <list><!--Be sure to navigate to classpath in a Web environment otherwise default to the current Web application to find--><value>classpath:i18n</value></ List></property><property name= "defaultencoding" value= "UTF-8"/><property name= "CacheSeconds" Value= "/></bean>"
Target page success.jsp
<%@ taglib uri= "http://java.sun.com/jsp/jstl/fmt" prefix= "FMT"%><!--introduced Jstl library--><fmt:message key= " I18n.username "></fmt:message><br/><fmt:message key=" I18n.password "></fmt:message> <br/>
Change the language of your browser to display different language versions.
PS: The above code in the index.jsp direct request is invalid, need to go through a spring controller forwarding to reach the success.jsp page is useful.
This article is from "Avatar" blog, please make sure to keep this source http://shamrock.blog.51cto.com/2079212/1603705
SPRINGMVC Study Notes-cont.