WEB乱码解决方法

1.JSP页面设置

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

 

 

2.servlet类设置

doGet方法:

  request.setCharacterEncoding("UTF-8");
  response.setContentType("text/html;charset=UTF-8");

doPost方法:

  request.setCharacterEncoding("UTF-8");
  response.setContentType("text/html;charset=UTF-8");

 

 

你可能感兴趣的:(Web)