我的servlet中:
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setCharacterEncoding("GBK");
String fromAccount = req.getParameter("from");resp.setContentType("text/html; charset=GBK");
java.io.PrintWriter out = resp.getWriter();
out.println(fromAccount);
out.println("你好");
}我已经设置接收参数的编码格式req.setCharacterEncoding("GBK");但我用
./WebTest?from=谢谢
调用则显示是乱码,而out.println("你好");则可以正常显示
除非我在程序中再转换一次才能显示中文
fromAccount = new String(fromAccount.getBytes("ISO-8859-1"), "GBK");
难道req.setCharacterEncoding("GBK");不起作用么?