HttpServletResponse中文乱码问题

SetCharacterEncoding

  1. response.setCharactorEncoding必须要在创建输出流之前,否则将会没有效果
  2. 使用方法
    	//这两个方法必须同时使用,并且必须先使用setContendType
        response.setContentType("text/html ");
        response.setCharacterEncoding("utf-8");
        
  3. 所以最好不要使用,而是用下面的方法

setContendType

  1. response.setContentType("text/html;charset=Utf-8");   MIME类型(比如:video/mp4,imge/jpg).
  2. 响应的乱码解决方法用这个就好

猜你喜欢

转载自blog.csdn.net/s88893325885/article/details/81750369