servlet向浏览器输出中文
//在前头加一句即可输出中文
response.setContentType("text/html;charset=gbk");
jsp表单提交的中文乱码
1:使用post方式提交 ,在servlet页面加一句
request.setCharacterEncoding("utf-8"); //utf-8与jsp设置的编码相对应
即可获取到中文
2:使用get方式提交 ,要对获取的值进行转化
比如获取到name
name = new String(name.getBytes("ISO8859-1"),"utf-8");
即可获取到中文
超链接的中文乱码
超链接是以get的方式传输,同样要对获取的值进行转化。