November 13 international web development training diary

Source: Internet
Author: User

I explained the role and Design Concept of displaytag, an open-source custom tag, and asked everyone to write such a programme program. The result was very bad!
Let's explain the internal execution principle of $ {X. name} and review the compilation details of iteration labels.

I explained what is the internationalization of applications and reviewed the locale settings of locale objects and operating systems. Explained the resource package management of resourcebundle:

Create messages first. properties, messages_en.properties, messages_zh.properties, messages_zh_cn.properties, and other files. The content of each file is the file name. This article introduces them as a resource package, and then writes the Java source program (using the default locale) to read the content, read the content in zh_cn, change zh_cn to zh_cnx, run the Java program, read the content in ZH, and change ZH to zhx, read the content in the default file. Restore all original file names, set locale in the source program to English, execute this program, see the content in en, change en to ENX, and then execute (Focus) after asking a question ), the contents in the zh_cn file are displayed! To explain the cause, change the locale of the operating system to English and execute it again. This is the content in the default file.
The native2ascii tool is used to convert the content in the Chinese resource file. A problem found during use: for "You/havip", native2ascii is not converted to "/". therefore, the conversion result is "/u4f60 // u597d", which leads to a problem when reading the content in the properties file. The Chinese content in the displaytag_zh_cn.properties file in appfuse is not processed with native2ascii. I really don't know who submitted it. It seems that there may not be many people who have studied Chinese thoroughly!

Next, I explained the internationalization problem in web development and how to obtain the locale information of the browser. The storage location of the properties file: resourcebundle is to search in the directory searched by the class loader, search under the root directory of the class.

I asked a question: is the final Cn of messages_zh_cn.properties case sensitive? JDK is used, Windows is used, and what is the situation in Linux?
Feng Weili experiment: In the JSP file under tomcat, only messages_zh_cn.properties can be read, but the messages_zh_cn.properties file cannot be read. If the zh_cn file is read successfully, changing zh_cn to zh_cn will not cause any problems, this is because the content in the zh_cn.properties file is cached in JSP. After modifying the JSP file, he re-accesses the file. The Tomcat background prompts that the zh_cn file cannot be found in webapp classloader, then, reload the entire web application and load the default resource file.
Wang Tao's experiment: The messages_zh_cn.properties file can be read in the JSP file under tomcat, and Tomcat will always cache the resource content, even if the zh_cn file is deleted and the JSP file is modified for re-access, there is no problem, unless you restart tomcat.
My advice to Feng Weili: Use the getresourceasstream method to read a resource file, delete the resource file, and check the access effect. The experiment result reported by Feng Weili is that the resource content is always cached in the class loader regardless of whether the JSP file is modified or not.

Next, we will explain how to assign values to parameters in a string through the messageformat object. We accidentally find that the array can be passed as an object from the format method of messageformat, this object is forcibly converted into an array within the method.

 

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.