servlet解决中文乱编的问题(7)
来源:未知 责任编辑:责任编辑 发表时间:2014-02-02 17:48 点击:次
throws ServletException, IOException {
response.setContentType("text/html;charset=GBK");
String newname = new String(request.getParameter("username").getBytes(
"ISO-8859-1"), "GBK");
PrintWriter out = response.getWriter();
out.print("<html><head></head><body>GET方式提交<br/><h2>" + newname);
out.print("</h2></body></html>");
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=GBK");
//request.setCharacterEncoding("GBK");
System.out.println("调用doPost");
String newname = request.getParameter("username");
PrintWriter out = response.getWriter();
out.print("<html><head></head><body>POST方式提交<br/><h2>" + newname);
out.print("</h2></body></html>");
out.close();
}
}
摘自 Mars学IT
相关新闻>>
- 发表评论
-
- 最新评论 更多>>