Flex Chinese issues, accessing Chinese path issues

Source: Internet
Author: User
Tags resource tomcat

This two days after a website, relatively simple two or three days to basically finish, but the most difficult is the flex of a Chinese problem, the following I would like to talk about three different kinds of phenomenon.

The first: The source address of the image component is Chinese, such as resources/Mathematics/Advanced Mathematics/math.jpg;

The section of the configuration port in the Server.xml in Tomcat plus the uriencoding= "Utf-8";

Direct access to resource addresses such as: http://localhost:8080/WebTest/resources/Mathematics/Advanced Mathematics/math.jpg;

In this case, the image component cannot be displayed, and the following directly accessed address can access the data.

The second: The source address of the image component is GBK, such as resources/Mathematics/Advanced Mathematics/math.jpg;

The section of the configuration port in the Server.xml in Tomcat plus the uriencoding= "GBK";

Direct access to resource addresses such as: http://localhost:8080/WebTest/resources/Mathematics/Advanced Mathematics/math.jpg;

In this case the image component can be displayed, but the directly accessed address is inaccessible to the data.

The third type: The source address of the Mage component is utf-8, such as resources/%e6%95%b0%e5%ad%a6/%e9%ab%98%e7%ad%89%e6%95%b0%e5%ad%a6/math.jpg;

The section of the configuration port in the Server.xml in Tomcat plus the uriencoding= "Utf-8";

Direct access to resource addresses such as: http://localhost:8080/WebTest/resources/Mathematics/Advanced Mathematics/math.jpg;

In this case the image component can be displayed, and the direct access to the address is also accessible to the data.

Reason Analysis:

Browser default encoding is Utf-8, flex in the address by default is Utf-8, and Tomcat default encoding is Iso-8859-1, that is, we visit the address is ISO-8859-1 encoded, If you do not set the encoding in Tomcat as the default Iso-8859-1 method, the Chinese in the request address in the browser cannot be parsed, so the resource is not requested, so By setting tomcat encoding to Utf-8, we can access resources that contain Chinese names through the browser. Similarly, by default, Flex components cannot access resources with Chinese paths;

If Tomcat is set to Utf-8, we can access an address similar to http://localhost:8088/EncodingTest/resource/unnamed. jpg, but for flex <mx:image source= " Resources/Sports/Football/1.jpg "/> Such a component still does not show (this I also doubt, also hope high man pointing), but we set to <mx:image source=" resources/%e4%bd%93%e8%82%b2 /%e8%b6%b3%e7%90%83/1.jpg "/> So we can access it.

If the tomcat encoding is set to GBK, the Flex component <mx:image source= "resources/Sports/Soccer/1.jpg"/> We can access it, but for <mx:image source= " Resources/%e4%bd%93%e8%82%b2/%e8%b6%b3%e7%90%83/1.jpg "/> Such we are inaccessible, for the address in the browser http://localhost:8088/ encodingtest/resource/unnamed. jpg, we are not reachable, but we replace the%CE%B4%C3%FC%C3%FB after the unnamed GBK encoding, that is, http://localhost:8088/ Encodingtest/resource/%ce%b4%c3%fc%c3%fb.jpg will be able to visit. As for how to get the Chinese GBK encoding we can get through the Java method, such as String s= "unnamed. jpg"; S=java.net.urlencoder.encode (S, "GBK"), thus obtaining the GBK encoding of "unnamed. jpg".

Summarized as follows:

This paper sums up a basic method to solve the Chinese coding, that is, the path that the component in Tomcat sets to access the resource in the Utf-8,flex. If you have Chinese then we will convert the Chinese to the Utf-8 format in the assigned to the component's Source property, The address that is accessed in the browser can be an access address with Chinese.

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.