SPRINGMVC Study Notes-cont.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.