(1) The JSP page is Chinese, but it is after it is garbled: solution is to the coded place in JSP page <% @ page language = "java" contenttype = "text / html; charSet = GBK"%> Because JSP is coded when the JSP is converted to the Java file, the default server is ISO-8859-1. If a JSP is directly entered in Chinese, JSP is handled as ISO8859-1 is definitely problematic, this One point, we can confirm by viewing JAVA intermediate files generated by Jasper (2) When obtaining the Chinese character code submitted by the Request object, there will be garbled: Solution to: To configure a filter, it is a servelet filter, as follows: import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax .servlet.ServletResponse; import javax.servlet.UnavailableException; / ** * Example filter that sets the character encoding to be used in parsing the * incoming request * / public class SetCharacterEncodingFilter implements filter {/ ** * Take this filter out of service * / Public void destroy () {} / ** * select and set (if specified) The character encoding to be used to * interpret request parameters for this request. * / Public void Dofilter (ServletReques t request, ServletResponse response, FilterChain chain) throws IOException, ServletException {request.setCharacterEncoding ( "GBK"); // passes control to the next filter chain.doFilter (request, response);} public void init (FilterConfig filterConfig) throws ServletException {}} configured web.xml
If you still have this situation, you will see if you have a fourth situation, your Form submitted data is not submitted by get, in general, if you submit it, there is no problem. If so, you will see the solutions solved in the fourth. There is also information about the information containing Chinese characters. The code is processed: package dbjavabean; public class code () {public code codingconvert () {//} public string TOGB (String Unistr) {String GBSTR = ""; if (Unistr = = NULL) {Unistr = "";} try {byte [] tempbyte = unistr.getbytes ("ISO8859_1"); GBSTR = New String (TempByte, "GB2312");} Catch (Exception EX) {} Return GBSTR;} Public String Touni (String gbstr) {string unistr = ""; if (gbstr == null) {GBSTR = "";} try {byte [] tempbyte = gbstr.getbytes ("GB2312"); Unistr = New String (Tempbyte , "ISO8859_1");} Catch (Exception EX) {} Return Unistr;}} You can also transform directly, first you will get the obtained string with ISO-8859-1, then store this code to one In-byte arrays, then convert this array into string objects, for example: string str = request.getParameter ("girl"); Byte B [] = Str.getbytes ("ISO-8859-1"); Str = new string (b); any information submitted correctly by the above conversion. (3) Returning in the server-only request. GetParameter ("Name") is garbled; Press Tomcat to set Filter and use Request.SetCharacterencoding ("GBK"); no matter what the problem is On the method of processing parameters: If you have a DOGET (HTTPSERVLETREST, HTTPSERVLETRESE RESPONS) method, even write: Request.SetCharacterencoding ("gbk"); response.setContentType ("text / html; charSet = GBK "); also does not work, return Chinese or garbled! ! ! If this function is changed to dopost (httpservletRequest request, httpservletResponse response) everything is OK. Similarly, the meaning of the display can be displayed in two JSP page processing forms is because the POST method is transmitted, it is still not possible to change to the GET method. This shows that in the servlet uses a doget () method or in the JSP to use the GET method to handle it.
This is, involving passing parameter information to pass through the browser, which is likely to cause conflicts of common character sets or do not match. The solution is: 1) Open Tomcat's server.xml file, find blocks, add the following line: uriencoding = "GBK" is the following:
To this step, basically completed a half, then you will write <% @ page language = "java" contenttype = "java" contentty = "text / html; charset = GBK"%>, the Label to the name is to Write
If you are through the data source link, you can't follow this way, first you have to write in the configuration file, configure the data source in Tomcat 5.0.19 is in C: / Tomcat 5.0 / Conf / Catalina / Localhost, the project I built is Workshop, the list of placed is WebApp, the configuration file of Workshop.xml is as follows: