首先实现这样一个页面 在doGet和doPost中写入: 输出的结果: doGet:乱码 doPost:乱码 解决方式: 1、添加语句 结果为:doGet:乱码 doPsot:正确 由此可以看出:request.setCharacterEncoding("UTF-8");这句在doGet方法中并不适用; 修改方案:修改doget方法为: 结果为:doGet:正确 doPost:正确 2、修改conf\server.xml文件中的 <Connectorport="8080"protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"/> 第一种:在末尾加上URIEncoding="UTF-8",然后运行检测 结果: doGet:正确 doPost:乱码 由此可知这种方法不行 第二种:在末尾加上useBodyEncodingForURI="true" 并在doGet()方法和doPost()方法中添加 结果: doGet:正确 doPost:正确 转载河软优快云乐知学院-李克