In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about how to solve the problem of garbled codes in Java EE. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
51CTO has introduced you to a lot of garbled problems, such as "in-depth analysis of Python Chinese garbled instructions", "description of Ado.Net code garbled introduction" and so on. This article makes a brief summary on the garbled code in Java EE, in order to throw a brick to attract jade, give you some reference. The problem of garbled code is a headache in Java EE. How to solve these problems, we must start with the crux of the problem in order to solve the problem quickly and accurately.
First of all, we know that the cause of garbled code is caused by different codes, which is like talking to an Indian, assuming that you do not understand Indian at all and the other person does not understand Chinese, then what you say will create question marks in each other's mind. So what should I do? The usual practice is to find a translator, which is the same with coding in Java. Let's look at an example.
Method 1:
1 2 3 4 user name: 5 6 7 8 this is a simple submission page Deom01.html input is:
The above is a JSP page that processes Deom01.html. Its purpose is to extract the value of Demo01 name and display it.
The input content is:?
When we typed Chinese into the page Deom01 and submitted it, we found that the content after submission was "?" Number, here, which is equivalent to the words spoken by people in different languages above, produces "?" The solution is to solve this problem through conversion:
The input is:
The garbled problem is solved by converting the obtained Byte value to a Byte array and then converting the unname array to the desired format.
Method 2:
Set uniform character encoding
Under the Javax.servlet.http package in API, there is a HttpServletRequest interface with such a method
Public void setCharacterEncoding (String env) throws UnsupportedEncoding
Its function is to set a uniform character encoding.
The input is:
Run after the change, and the result is the same as the previous one.
(note: the scope of GBK is larger than GB2312, GB2312 only refers to simplified Chinese, while GBK not only refers to simplified Chinese, but also includes traditional Chinese and other Chinese. )
These are just the two ways we summed up to solve the problem of garbled codes. Different methods are needed for different problems. I hope we can draw on our collective wisdom, find the crux of the problem and prescribe the right remedy to the case!
After reading the above, do you have any further understanding of how to solve the garbled problem of Java EE? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.