This is what I encounter when exchanging data with Servlet, response.getWriter () write ( "") will write Chinese garbled, go online inquiry solution is to add these two sentences at the beginning:
response.setCharacterEncoding ( "utf-8"); // set utf-8 encoded using HttpServletResponse response.setHeader ( "Content-Type", "text / html; charset = utf-8"); // set the encoding of the response headers
The respective heads provided herein is a notification client or coding scheme used by the browser. But I still will not add these two, and finally found the eclipse will be there at the beginning when you create a servlet
response.getWriter().append("Served at: ").append(request.getContextPath());
I've been ignoring this sentence, that sentence must be added two response.getWriter () before calling, but I added it back in, so adding in a statement that the two will not work, then put the two statements before adding to it, the problem is solved.