Aikz

往客户端回传字符串数据

Response代码:
  

 

 

web配置文件代码:

 

 

   

    

    解决响应中文乱码问题:

    web程序中代码:

    

 

 

     网页显示:

    

 

 

   解决方法:

  获取默认字符集:   

  System.out.println(resp.getCharacterEncoding());

  自定义字符集  resp.setCharacterEncoding("UTF-8");

  

 

 

   同时也要设置浏览器字符集格式为UTF-8

    (两种方式都可以,如果第一种无效的话就是用第二种方式)

      1. resp.setHeader("Content-Type","test/html; charset = UTF-8");
2. resp.setContentType("text/html:charset=UTF-8");  【 resp.setContentType()此方法必须在获取流对象之前调用才有效】

 

 

 

 

  解决后页面显示:

  

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-08-15
猜你喜欢
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-10-11
相关资源
相似解决方案