字符串亂碼處理

//處理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");
相關文章
相關標籤/搜索