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(){

}

}

相关文章:

  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
猜你喜欢
  • 2022-02-22
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案