关于网页的乱码

一、在html中乱码的解决方法:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

charset也可以设置成GBK,可消除乱码

二、Servlet中乱码解决方法:
response.setContentType("text/html;charset=GBK");
  请求中有汉字,出现乱码时:

(1)用doPost方法时

request.setCharacterEncoding("utf-8");

(2)用都doGet方法时

在<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />标签的末尾加URTEncoding="utf-8"

即:<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URTEncoding="utf-8" />

先写这些吧!以后积累了再修改吧!

你可能感兴趣的:(关于网页的乱码)