In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you how to solve the Java/J2EE Chinese problem, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Most programmers have encountered Java Chinese problems in programming, but as long as you know the Chinese problem principle of the Java system, we can say goodbye to the Chinese problem.
The oldest solution is to use String bytecode conversion, this kind of solution is inconvenient, we need to destroy the object encapsulation, bytecode conversion.
Another way is to set the coding of the J2EE container. If the J2EE application system is separated from the container, garbled will occur, and the specified container configuration does not comply with the principle of separating the J2EE application from the container.
In the internal operation of Java, all the strings involved are converted to UTF-8 encoding for operation. So, what kind of character set is a string before it is converted by Java? Java always determines the initial encoding of strings according to the default coded character set of the operating system, and the input and output of the Java system adopt the default encoding of the operating system.
Therefore, if the input and output of the Java system and the coded character set of the operating system can be unified, the Java system will be able to process and display Chinese characters correctly. This is a principle of dealing with Chinese characters in Java system, but in practical projects, it is difficult to correctly grasp and control the input and output of Java system. In J2EE, the problem of garbled code in Chinese is very prominent because it involves external browsers and databases.
The J2EE application runs in a J2EE container. In this system, there are many ways to input: one is packaged into a request (request) through the page form to send to the server; the second is read through the database; and the third kind of input is more complex, JSP in the * run time is always compiled into Servlet,JSP often contains Chinese characters, then the compilation using javac, Java will be based on the default operating system code as the initial coding. Unless otherwise specified, the default character set can be specified in Jbuilder/eclipse.
There are also several ways to output: * the output of JSP pages. Because the JSP page has been compiled to Servlet, the output encoding will also be selected based on the default encoding of the operating system, unless you specify the output encoding, and the output path is the database, which outputs the string to the database.
From this point of view, the input and output of a J2EE system is very complex and dynamic, while Java runs across platforms. In actual compilation and operation, different operating systems may be involved. If Java is allowed to freely determine the coded character set of input and output according to the operating system, there will be uncontrollable garbled.
Java is a cross-platform language, so the problem of character set must be solved by specific systems, so in a Java application system, the fundamental way to solve Chinese garbled is to clearly specify the unified character set of the whole application system.
On how to solve the Java/J2EE Chinese problem to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.