I "A. jsp? Param = Chinese "PASS Parameters, request. getparameter (PARAM); Receive this parameter, I add a uriencoding =" gb2312 "to the conf directory of Tomcat"
The received parameters will not be garbled!
However, if you want to open a link to a Chinese Document on the page, click "Learn More" to open this PDF document. The page reports the following error:
HTTP status 404-/data/% E9 % A3 % 9e % E8 % a1 % 8C % E6 % 89% 8B % E5 % 86% 8C/%e9%a3%9e%e8%a1%8c.pdf
--------------------------------------------------------------------------------
Type status report
Message/data/% E9 % A3 % 9e % E8 % a1 % 8C % E6 % 89% 8B % E5 % 86% 8C/%e9%a3%9e%e8%a1%8c.pdf
Description the requested resource (/data/% E9 % A3 % 9e % E8 % a1 % 8C % E6 % 89% 8B % E5 % 86% 8C/%e9%a3%9e%e8%a1%8c.pdf) is not available.
--------------------------------------------------------------------------------
I checked the relevant information online, almost all web containers in its internal default character encoding format is ISO-8859-1 as the default value, at the same time, almost all browsers in passing parameters are by default in the way of UTF-8 to pass Parameters, I link the Chinese PDF file, ie is using the UTF-8 to pass Parameters, so I have
Tomcat directory conf directory server. xml uriencoding = "gb2312" changed to uriencoding = "UTF-8" so that the Chinese link problem is solved!
But what about A. jsp? Param = Chinese "when passing parameters, request. getparameter (PARAM) becomes garbled again. How can we solve these two problems at the same time! Please give advice online! My page has been added:
<% @ Page contenttype = "text/html; charset = gb2312" errorpage = "error. jsp" %>
<% @ Page pageencoding = "gb2312" %>
<% Request. setcharacterencoding ("gb2312"); %> the three statements are complete!
Use UTF-8 for all encoding-related requests. Try again.
<% @ Page contenttype = "text/html; charset = UTF-8" errorpage = "error. jsp" %>
<% @ Page pageencoding = "UTF-8" %>
<% Request. setcharacterencoding ("UTF-8"); %>
Didn't I write request. setcharacterencoding ("gb2312")? I have encountered this problem before.
Zxm_dgcstars:
After changing to UTF-8, there are two problems:
1) After refreshing the page, click the Chinese character. A. jsp? Param = Chinese "PASS Parameters, request. getparameter (PARAM );
Next is & #65533; & #65533; & #65533; & #65533; & #65533; & #1458; & #65533; & #65533; & #65533; & #65533; & #65533; & #65533; & #1458; & #65533; (Garbled text). However, when I click another Chinese character, the other page is not garbled, why is it garbled for the first time?
2) changed to UTF-8, my page originally defined CSS have changed, for example, the two Chinese words below the original no underline, changed to UTF-8, the following underline, my CSS does not work! Is CSS related to encoding? How to adjust it? My CSS definition is as follows:
Body, table {
Background-color: # ccffff; font-size: 9pt; Word-Spacing: 2pt; color: #333333; font-family: ""; letter-Spacing: 0.5pt
}
A: link {
Color: #000000; font-style: normal; text-Decoration: None
}
A: visited {
Color: #000000; font-style: normal; text-Decoration: None
}
A: hover {
Color: # f77d08; font-style: normal; text-Decoration: None
}
A: active {
Color: # 0066cc; font-style: normal; text-Decoration: None
}
. En {
Font-size: 12px; font-family: "Arial", "Helvetica", "Sans-serif"
}
Body {
SCROLLBAR-FACE-COLOR: # eeeeee; font-size: 9pt; SCROLLBAR-HIGHLIGHT-COLOR: # b5b5b5; SCROLLBAR-SHADOW-COLOR: # b5b5b5; color: #000000; SCROLLBAR-3DLIGHT-COLOR: # eeeeee; line-Height: 12pt; SCROLLBAR-ARROW-COLOR: # b5b5b5; font-family: ""; SCROLLBAR-DARKSHADOW-COLOR: # eeeeee
}
. 3 dfont {
Filter: glow (color = ffffff, strength = 0) shadow (color = aaaaaa, direction: 75); position: relative; width: 100%
Jiaozi226 ():
I wrote:
<% @ Page contenttype = "text/html; charset = gb2312" errorpage = "error. jsp" %>
<% @ Page pageencoding = "gb2312" %>
<% Request. setcharacterencoding ("gb2312"); %> the three statements are complete!
I transfer a Chinese document, link a Chinese document name, and open a PDF or Word document when I click "Learn Chinese Document" or "learn. Word" on the webpage. I can click a PDF or word in the English name! For example, loveworkflow or love. Word. In conflict, only one problem can be solved at a time, and two problems cannot be solved at the same time!
What eclipse do you use? You can try to change the template file to Chinese. It should be automatically recognized when it is created later.
Directly change the template file to Chinese? How can this problem be solved? I used eclipse3.2, myeclipse5.0
In the window-preferences, select wdb and XML. There is a JSP, which can be encoded as Chinese.
Set two properties in charset = "gb2312" encoding = "gb2312"
Cucaracha (batistta ):
What do you mean?
I wrote:
<% @ Page contenttype = "text/html; charset = gb2312" errorpage = "error. jsp" %>
<% @ Page pageencoding = "gb2312" %>
<% Request. setcharacterencoding ("gb2312"); %>
You asked me to set two properties charset = "gb2312" encoding = "gb2312 "??
Is it written:
<% @ Page contenttype = "text/html; charset = gb2312"
Encoding = "gb2312" errorpage = "error. jsp" %>
Is that what it means?
Believebase ():
Where can I find wdb and XML in my preferences?
Use the following before passing your Chinese ParametersCodeEncoding:
String param1 = urlencoder. encode ("your Chinese Parameters", "UTF-8 ")
Then in A. jsp? Param = param1 (the parameter after transcoding );
You can use the following code to obtain parameters when obtaining parameters:
String param1 = urldecoder. Decode ("the encoded parameter passed", "UTF-8"); // turn Chinese in!
Sunny319 (learning Java .):
In this sentence, what package do you want to export? Urlencoder error! Add something before!
String param1 = urlencoder. encode ("your Chinese Parameters", "UTF-8") // if I write this sentence on my page, it will report
Urlencoder cannot be resolved.
Related code on my page:
String param1 = urlencoder. encode ("filenames [N]", "UTF-8 ");
My JS:
Onclick = "notinpropertiesturnit ('<% = param1 %>', content <% = n %>, IMG <% = n %>, tag <% = n %> );"
Function notinpropertiesturnit (manualname, SS, II, BB ){
Self. Parent. Frames ["mainframe"]. Location. href = "notinpropertiestr. jsp? Manualname = "+ manualname;
}
How can I write another page? The page code for getting parameters:
String A = request. getparameter ("manualname ");
Is this the case?
String A = urldecoder. Decode ("manualname", "UTF-8"); // urldecoder cannot be resolved, add something!
Add this on the page
<% Request. setcharacterencoding ("UTF-8"); %>
Unchanged XML
Import java.net. urlencoder;
Import java.net. urldecoder;
Changed:
String A = request. getparameter ("manualname ");
A = urldecoder. Decode (a, "UTF-8 ");
After your Chinese parameter encoding, the connection in the address bar should be: a. jsp? Param = % AB % BC!
Zhangfan790913 (Xiaoyue ):
Does XML remain unchanged? Does the server. xml file remain unchanged? My original server. xml and uriencoding = "UTF-8" this sentence, you do not let add this sentence? Write these two sentences on my page, right:
<% @ Page contenttype = "text/html; charset = gb2312" %>
<% Request. setcharacterencoding ("UTF-8"); %>
My server. xml file does not have that sentence, and the page also uses <% request. setcharacterencoding ("UTF-8"); %>
Now, one of the two problems is not solved! I still solved a problem! Now the link to open Chinese is garbled, and the passing of Chinese parameters is garbled. Your method is useless!
I want to link the document. DOC file on my page. After the mouse clicks: Garbled !!
HTTP status 404-/data/EEE/%e6%96%87%e6%a1%a3.doc
--------------------------------------------------------------------------------
Type status report
Message/data/EEE/%e6%96%87%e6%a1%a3.doc
Description the requested resource (/data/EEE/%e6%96%87%e6%a1%a3.doc) is not available.
Chinese parameters are also garbled:
??????? Á? ?? Why ?? Á
Worried! How can this problem be solved!
%E6%96%87%e6%a1%a3.doc this is not garbled. It's just that Chinese characters are encoded in a encoding format! You can restore it to Chinese!
Sunny319 (learning Java .):
Before you talk about your method, I need to add this sentence of server. xml:
Adding uriencoding = "UTF-8" in server. xml // Adding only this sentence can solve the problem of opening the Chinese file name in the page Link:
For example, if I want to link the document file .doc on my page, I can open this word document after adding this sentence, but the page is passed to Chinese, and the other page receives this Chinese, garbled characters are received on the other page ??????? ???????
I followed your method or garbled! My address bar is not displayed! Because I have multiple windows, a large JSP is divided into three small JSPs, and the parameter I pass is transferred from a small JSP to another small JSP.
Do you have MSN? I will send you the file. I am MSN:
Mengnansoftware@hotmail.com
Sunny319 (learning Java .):
2017e63799610987347e6379a1347a3.doc is an encoding format. How can we restore it to Chinese ??? Let's talk about the specific method! I am in a hurry! Server. xml?
Jsp1.jsp? Name = "" submitted to jsp2.jsp
In jsp2
String STR = request. getparemeter ("name ");
String Param = new string (Str. getbytes ("ISO-8859-1"), "GBK ");
Dr_lou ():
Can I change server. xml?
After I added uriencoding = "UTF-8" to server. XML, I Still garbled with your method!
String A = request. getparameter ("manualname ");
String Param = new string (A. getbytes ("ISO-8859-1"), "gb2312 ");
Out. println (PARAM );
The page is still garbled !???????
Dr_lou ():
When the cursor file is hit, the following error is reported:
HTTP status 404-/data/EEE/%e6%96%87%e6%a1%a3.doc
--------------------------------------------------------------------------------
Type status report
Message/data/EEE/%e6%96%87%e6%a1%a3.doc
Description the requested resource (/data/EEE/%e6%96%87%e6%a1%a3.doc) is not available.
Server. XML with uriencoding = "UTF-8" can solve the problem of opening the link to the Chinese file, but can not solve the problem of passing Chinese parameters, do not add uriencoding = "UTF-8", add
String A = request. getparameter ("manualname ");
String Param = new string (A. getbytes ("ISO-8859-1"), "gb2312 ");
Out. println (PARAM );
It can solve the problem of passing Chinese parameters, but cannot solve the problem of opening the link to a Chinese file!
How can we solve these two problems at the same time ?? Thank you !! Depressed!
Connect values in Servlet
String book_pai_name = new string (request. getparameter ("book_pdf"). getbytes ("ISO-8859-1"), "gb2312 ");
Add a value to the JSP page
Change getbytes ("ISO-8859-1") to getbytes.
Ran_ran ():
What do you mean? I wrote JSP + JavaBean.ProgramAh! What are you talking about? My requirement is to pass Chinese parameters and open the link to a Chinese file on the page. Either problem can be solved! The methods described by many people only solve one of the problems, and the other is not solved at all!
I didn't see it clearly''
I recently made a news publishing system.
The link for transferring Chinese characters and opening Chinese Files Between Leaf Surfaces
I sent it to you on QQ 397692925.
The link in Chinese seems to only add things to <% @ page without modifying XML
Dr_lou ():
Can I send it to my mailbox? Mengnansoftware@hotmail.com, I am on MSN now! I cannot go to QQ during the day and can only go to QQ at night. My QQ: 565355525
There is also the zxm_dgcstars () method. When I click the link to a Chinese file for the first time, garbled characters are passed in. The second time I click this link to upload a Chinese file, it is not garbled and I don't know what's going on, in addition, the original CSS links do not have a horizontal line. The zxm_dgcstars () method has a horizontal line! Do not understand! Others will not reply to my post!
The method is to modify the XML, and then add the following to the page:
<% @ Page contenttype = "text/html; charset = UTF-8" errorpage = "error. jsp" %>
<% @ Page pageencoding = "UTF-8" %>
<% Request. setcharacterencoding ("UTF-8"); %>
Paying attention
Do not use GBK. It is best to use UTF-8 or iso8859-1 everywhere.
Just finished testing
Jsp1.jsp
<% @ Page contenttype = "text/html; charset = GBK" %>
<Head>
</Head>
<Body bgcolor = "# ffffff">
<Form action = "jsp2.jsp? Name = Xu "method =" Post ">
<Input type = "file" name = "FILENAME"/>
<Input type = "Submit"/>
</Form>
</Body>
Jsp2.jsp
<% @ Page contenttype = "text/html; charset = GBK" %>
<Head>
</Head>
<%
Request. setcharacterencoding ("GBK ");
String str1 = request. getparameter ("name ");
String str2 = request. getparameter ("FILENAME ");
String gbk1 = new string (str1.getbytes ("ISO-8859-1"), "GBK ");
%>
<Body bgcolor = "# ffffff">
"Target =" _ blank "> <% = gbk1 %>
</Body>
Enable the hyperconnections with Chinese characters
Dr_lou ():
What you said is not in line with my needs! I made a link on one page, and Connected Parameters on the other. You made a link and parameters on the same page!
Does anyone know how to solve this problem! Depressed!
Sunny319 (learning Java .):
2017e63799610987347e6379a1347a3.doc is an encoding format. How can we restore it to Chinese ??? Let's talk about the specific method! Wait for you to reply!
My server configuration file is as follows:
Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
Enablelookups = "false" redirectport = "8443" acceptcount = "100"
Connectiontimeout = "20000" disableuploadtimeout = "true" uriencoding = "UTF-8" usebodyencodingforuri = "true"/>
My web project name is strutstest
Write a test action and put a file named "Chinese .txt" under strutstest"
System. Out. println ("test ");
String TST = Req. getparameter ("Chinese ");
System. Out. println (TST );
Try {
System. Out. println (new string (TST. getbytes ("ISO-8859-1"), "gb2312 "));
} Catch (unsupportedencodingexception e ){
E. printstacktrace ();
}
Return Mapping. findforward ("page ");
Test 1
Http: // MAID: 8080/strutstest/search. do? Chinese = Chinese 1111111111
Console:
Test
???? 1111111111
Chinese 1111111111
Test 2
Http: // 127.0.0.1: 8080/strutstest/Chinese .txt
The displayed content is normal.
The key lies in usebodyencodingforuri = "true"
Dear friends, sorry, we only accept 50 points for the transfer.
Syoumei (good teachers let you go to heaven, bad teachers let you stay in the suite !) :
I add these two uriencoding = "UTF-8" usebodyencodingforuri = "true" or can only solve the problem of link to open the Chinese file ah, that pass Chinese or garbled ah !! What does usebodyencodingforuri = "true" mean?
Your console is printed as follows
Test
???? 1111111111
Chinese 1111111111
Not here, too ???? ?
Me MSN: mengnansoftware@hotmail.com
QQ: 565355525
System. Out. println ("test"); // Test
String TST = Req. getparameter ("Chinese ");//???? 111111
System. Out. println (new string (TST. getbytes ("ISO-8859-1"), "gb2312"); // 1111111111 Chinese
<% @ Page contenttype = "text/html; charset = gb2312" %>
<% = New string (request. getparameter ("Chinese"). getbytes ("ISO-8859-1"), "gb2312") %>
It's okay to use it directly on a JSP page.
My page is still garbled. Do you have MSN or QQ? I add you, and I will send you my JSP page code!
<% Request. setcharacterencoding ("gb2312"); %>
In fact, you don't need to worry about garbled code. You only need to use a gb312 file. As for garbled code, you may encounter an error with your JSP code...
Icannotfly ():
You don't want to read the content of my post at all. Please take a look! You added that sentence!
Up
It's also a garbled problem. If you haven't guessed it wrong, you are working on a system similar to news publishing.
Those connections are obtained from the database, and then displayed normally on the first page, and garbled characters are displayed on the second page, including normal access to the address bar on the second page, I used to have this problem.
Csdn is not what you think, like cloud! The average person also copies each other, and the answer is not enough.
I still read the book by myself. I remember that I used to score 100 points. Many people did not solve this problem.
You can solve the problem by yourself.
One of the upstairs may be right, using urlencoder and urldecoder. However, when I was using it, I also said that the class could not be found, but it has already been imported.
In addition, this method is found on the internet, specifically for passing parameters in Chinese, and you need to add uriencoding = "utf8"
I read a book and checked the information for a long time.
Suggestion: utf8 encoding is used for both databases and pages.