首页 > 其他 > 详细

request.getParameter中文乱码问题

时间:2014-04-13 02:13:50      阅读:439      评论:0      收藏:0      [点我收藏+]

1、获取URL的值为乱码(GET)

String para=new String(request.getParameter("para").getBytyes("iso8859-1"),"gb2312");

2、获取Form的值为乱码(POST)

使用过滤器

配置EncodingFilter;

public class EncodingFilter Implements Filter{

public void init(FilterConfig fconfig)throws ServletException{

}

public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws Exception{

  request.setCharacterEncoding("utf-8");//根据你的页面设置

  System.out.println("------------Change Encoding OK!----------");

     chain.doFilter(request,response);

}

public void destroy(){

}

}

request.getParameter中文乱码问题,布布扣,bubuko.com

request.getParameter中文乱码问题

原文:http://www.cnblogs.com/zailushang117/p/3661182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!