解决中文参数出现的乱码问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35219609/article/details/77942860

1、利用new string(param.getbytes("iso-8859-1"),"utf-8")

      例子:String username=request.getParameter("username");
username=new String(username.getBytes("iso-8895-1"),"utf-8");

2、利用request.setCharacterEncoding("utf-8");设置请求参数的编码类型,进行整体转换,默认情况下只适合post提交方式

3、创建一个编码集过滤器,工程下所有的请求执行前先执行过滤器里面的代码

猜你喜欢

转载自blog.csdn.net/qq_35219609/article/details/77942860