HttpServletRequest解决中文乱码的问题
2015-09-19 00:10
381 查看
HTTP请求有get和post,这两中方式解决中文乱码的方式如下:
1.Post方式请求
2.Get方式请求
1.Post方式请求
//这句话是设置post请求体的编码为utf-8 request.setCharacterEncoding("utf-8"); //获取请求参数 request.getParameter("username");
2.Get方式请求
new String(request.getParameter("username").getBytes("ISO-8859-1"),"utf-8");
相关文章推荐
- 基于BS架构开发聊天室 采用while(true)方式接收消息,不关闭http请求
- 在Action类中获得HttpServletResponse对象的四种方法
- IIS不能访问映射的网络驱动器
- Socket学习网络基础准备
- PING命令 原理
- Http协议讲义及相应过程
- Android网络上获取图片的三种方法
- HDU_3998_Sequence(最长上升子序列 + 网络流)
- 网络扫描常用命令
- RMI、Hessian、Burlap、Httpinvoker、WebService的比较
- 把网络请求得到的字符串转成字典
- Tcp/ip三次握手,4次分手.
- SqlServer问题:sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“Connectio
- 漫步云中网络
- HttpServletResponse输出的中文乱码
- python网络爬虫
- http content-type
- VMware的三种网络连接方式
- http 的get,put,post,delete
- Http的Cache机制