post: 軟編碼
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
get:
軟編碼
1:修改tomcat
conf文件夾下~~~》server.xml line69~~~》
useBodyEncodingForURI="true"
2:硬編碼
public void doGet(HttpServletRequest request
,HttpServletResponse response)throws Exception{
String name = request.getParameter("key");
String newName = change(name);
}
public String change(String old){
try{
return new String(old.getBytes("iso-8859-1"),"utf-8");
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}