this blog is original: Integrated still Silicon Valley (http://www.atguigu.com) System tutorial (deep thank) and network of existing resources (blogs, documents, books, etc.), the source of resources I will markThe purpose of this blog: ① summary of their own learning process, equivalent to study notes ② to share their own experience to everyone, learn from each other, communication, not commercialcontent inevitably appear problems, welcome to correct, exchange, discussion, you can leave a message, can also be contacted by the following ways. I Internet technology enthusiasts, Internet technology enthusiastsWeibo: Ivan is in 0221qq:951226918
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------
Two levels: JSP input, JSP acquisition
1. enter Chinese on JSP page, no garbled characters after request page
1) Ensure that the encoding format of the JSP page is UTF-8
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%>
CharSet pageencoding Consistent, value is UTF-8
2) browser display character encoding consistent with the requested JSP page encoding
2. get The Chinese parameter value in the JSP page: the encoding used by the default parameter in transit is iso-8859-1
1) for post requests: call request.setcharacterencoding ("UTF-8") before getting the parameters;
1 <%2 request.setcharacterencoding ("UTF-8");3 4 %>5Username<%=Request.getparameter ("username") %>
2) for GET requests:
① first get the parameters, then decode, then encode
1 <%2 StringVal=Request.getparameter ("username");3 Stringusername= New String(Val.getbytes ("iso-8859-1"),"UTF-8");4 Out.print (username);5 6 %>
② General Method: Set Tomcat server.xml to add usebodyencodingforuri= "true". This can be used in the same way as the Post method to solve Chinese garbled
1 < port= "8080" protocol= "http/1.1"2connectiontimeout = "20000"3redirectport= "8443"4 Usebodyencodingforuri= "true"/>
Reference: The Usebodyencodingforuri property of the http://localhost:8080/docs/config/index.html document. Add this property for connector, set to True
Also modify the Tomcat mappings in Eclipse to add the same content
Reference:
Tomcat can start normally in 1.eclipse, but the browser cannot access the Tomcat homepage problem solving
[Original]java Web Learning Note 17: Questions about Chinese garbled and Tomcat started successfully in Eclipse, the homepage is not open