字符串乱码处理

//处理Request
request.setCharacterEncoding("utf-8");
String name = request.getParameter("username");
String newName =new String(name.getBytes("iso-8859-1"),"utf-8");
System.out.println("您输入的是:"+newName);

//处理Rsponse
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
相关文章
相关标签/搜索