第三章,jsp内置对象的文字乱码处理

来源:互联网 发布:start here mac.app 编辑:程序博客网 时间:2024/05/17 03:53

1.request对象是在服务器启动时自动创建
2.获取用户提交信息乱码处理方式
方法一:request.setCharacterEncoding(“utf-8”);
方法二:String str=new String(request.getParameter(“name”).getBytes(“iso-8859-1”));
方法三:定义方法
<%!public String toChinese(String str) throws java.io.UnsupportedEncoding-Exception
{byte b[]=str.getBytes(“iso-8859-1”);
str =new String(b);
return str;
}
%>
post提交方式三种方式都可以使用
get提交方式只能用后两种方式

0 0