- request獲得中文參數(shù)亂碼問(wèn)題
//兩種解決方法
//方法一
byte[] bytes= name.getBytes("ISO-8859-1");
name = new String(bytes,"UTF-8");
//方法二
request.setCharacterEncoding("UTF-8");
//方法二只對(duì)post提交方式有效
- response返回中文亂碼問(wèn)題
response.setContentType("text/html; charset=UTF-8");
- 跳轉(zhuǎn)
//服務(wù)端跳轉(zhuǎn),地址欄并不會(huì)改變
request.getRequestDispatcher("success.html").forward(request, response);
//客戶(hù)端跳轉(zhuǎn)它褪,重定向
response.sendRedirect("fail.html");