Problem Description: 1 The data submitted by the form is garbled with the string returned by Request.GetParameter ("XXX") or? ? 2 Directly via URL such as http: ///localhost/a.jsp? Name = China, such GET requests are garbled when using Request. GetParameter ("name"); Press Tomcat4 to set Filter Or use Request.SetCharacterencoding ("GBK"); no use. Cause: 1 Tomcat J2EE Implementation Parameters Timed by the POST method prompt time processing parameters Using the default ISO-8859-1 Processing 2 Tomcat Submitted by the GET method to use the Query-String process with the post method is different. Handling method. (Different from Tomcat4, set the setcharacterenceeEncoding ("GBK"). Solution: First all JSP files are plus: <% @ page contentType = "text / html; charset = GB2312"%> 1 Implement a filter. Set the processing character set to GBK. (There is a complete example in Tomcat's WebApps / Servlet-Examples directory. Please refer to Web.xml and setcharacterencodingfilter configuration.) 1) Just install the% Tomcat installation directory% / WebApps / servlets-example / web-inf / class / filters The /SetCharacterencodingFilter.class file is copied to your webapp directory / filters, if there is no Filters directory, create one. 2) Join the following lines in your web.xml:
Blocks, add as follows:
Uriencoding = "GBK"
Complete should be as follows:
Port = "80" maxthreads = "150" minsparethreads = "25" maxsparethreads = "75" Enablelookups = "false" redirectport = "8443" acceptcount = "100" Debug = "0" ConnectionTimeout = "20000" DisableUploadTimeout = "True" Uriencoding = "GBK" /> 2) Restart Tomcat, everything OK. Perform the following JSP page page test is successful <% @ Page ContentType = "text / html; charset = GB2312"%> <% @ Page Import = "java.util. *"%> <% String Q = Request.getParameter ("Q"); Q = Q == NULL? "No value": q; %>
You are submitted:
<% = q%>