关于使用request.getParameter()得到中文乱码的问题,在网上查找了一天终于找到了一个解决方案,是一个比较笨的方法,要在每个使用request.getParameter()的地方添加如下代码,代码如下:

1 String name=request.getParameter("name");
2 if(name!=null){
3     name=new String(name.getBytes("ISO8859_1"),"utf-8");      
4 }

PS:对于另外一种方法,就是使用

request.setCharacterEncoding("utf-8");

我试过,不起作用,具体原因我也不知道是为什么,希望有大神可以解答一下。

    

相关文章:

  • 2021-12-08
  • 2021-11-23
  • 2021-06-13
  • 2021-11-28
  • 2021-12-08
  • 2021-12-08
  • 2021-11-23
猜你喜欢
  • 2021-10-28
  • 2021-09-24
  • 2021-09-29
  • 2021-11-23
  • 2021-11-23
  • 2021-11-28
相关资源
相似解决方案