服务器那端根据表单中提交的name取值
解决乱码问题:
//对post有效,在request.getParameter("");之前写
reuest.setCharacerEncoding("UTF-8");
//对get有用,又称为手动。超链接中如果传递中文就用这种方法解决。
①String userName = request.getParameter("userName");
username = new String (usernae.getBytes("ios-8859-1"),"UTF8"); //先解码,再编码
②通过修改tomcat里面的service.xml文件为Connector节点添加useBodyEncodingForURI="true"属性即可[port = 8989]
可以参照:http://localhost:8989/docs/config/index.html文档的userBodyEncodingForURI属性(必须先开Tomcat)
Response解决乱码问题:
response.setContentType("text/xml; charset=utf-8");