[Original]java Web Learning Note 17: Questions about Chinese garbled and Tomcat started successfully in Eclipse, the homepage is not open

Source: Internet
Author: User
Tags java web tomcat server

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.