My servlet looks like this
protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
PrintWriter out=response.getWriter();
out.println("<Html><Head><Title>Signup</Title></Head>\n<Body>\n");
out.println("\u5982 电话\n");
out.println("</Body>\n</Html>");
}
My browser can display Chinese characters from other websites.
I’m trying 2 different ways to display Chinese characters, but they all showed up as ???
What’s the correct way to do it ?
No explicit encoding has been set for the response. The response would therefore be written by the container with the default encoding of ISO-8859-1.
You’ll therefore need to specify the appropriate character encoding using the HttpServletResponse.setCharacterEncoding() or HttpServletResponse.setContentType methods. This would be either of:
You may also use UTF-8 as the explicit encoding.