In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the solution of Chinese garbled code in JSP". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "JSP Chinese garbled solution" it!
For the common countermeasures of Chinese processing, the main ones that can be seen on the Internet are as follows:
<% @ page
ContentType= "text/html;charset=gb2312" >
Or:
<%
String Hi= "Hello"
Byte []
Tmpbyte=Hi.getBytes ("ISO8859_1")
Hi=new
String (tmpbyte)
Out.print (Hi)
% >
Mainly used the above two methods to modify, so as to become version 1.1.
To sum up briefly, the Chinese processing in the example takes place in the following places:
1 Chinese parameters are attached to url, which can be read directly.
For example:
<% = request.getParameter ("showword")% >
2 various sql operations related to database
There is no problem with the Access used here.
3 read HTML
The Chinese value submitted in the form form
It needs to be coded in jswdk, which can be written in simpler ways such as:
String name1=new
String (request.getParameter ("user_id") .getBytes ("ISO8859_1"))
In addition, with the support of jdk1.3, there is no need to join
<% @
Page contentType= "text/html;charset=gb2312"
% >
Under jdk1.2.2, it is unstable even if the two methods are used at the same time.
On the resin platform, the situation is better. Just add to the first line of the page:
<% @
Page contentType= "text/html;charset=gb2312"
% >
Chinese can be handled correctly.
If you add the code, it will be wrong.
5 Chinese included in session
In jswdk, the strange thing is that the values read from form can be displayed correctly if they are encoded
However, it is not possible to directly assign a Chinese value.
The resin platform is very good, ditto.
6 Chinese is displayed correctly after assigning a Chinese value to the variable.
For example, the following procedure:
<% @ page contentType= "text/html;charset=gb2312"
% >
< html > < head > < / head > < body >
<%
String
Hi= "Hello"
Byte [] tmpbyte=Hi.getBytes ("ISO8859_1")
Hi=new
String (tmpbyte)
Out.print (Hi)
% >
< / body > < / html >
Also in jswdk1.0.1, the above representation has no problem in jdk1.2.2, but cannot be displayed in jdk1.3.
Resin platform is very good, same as above, after testing, you only need to add it in < head >.
< meta
Http-equiv= "Content-Type" content= "text/html
Charset=gb2312 ">
Do not need <% @ page
ContentType= "text/html;charset=gb2312"% > can also display Chinese correctly.
At this point, I believe that everyone on the "JSP Chinese garbled solution" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.