public class FeedUpdaterServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
req.setCharacterEncoding("utf-8");
resp.setLocale(Locale.TAIWAN);
resp.setContentType("text/html; charset=utf-8");
resp.setCharacterEncoding("utf-8");
resp.getWriter().println("Hello, world!!@!");
out.println("我是人"); //some chinese character
out.println(resp.getCharacterEncoding());
out.flush();
out.close();
}
}
web xml
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>zh_TW</locale>
<encoding>utf-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>
Output: Hello, world!!@! ??? ISO-8859-1
It seems that the encoding of the respond can not be changed, what is happening???
Comments
Post a Comment