1.html 亂碼 1 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 2.jsp 亂碼頁面開頭加入 <%@ page language="java" import="java.util.*" content ...
1.html 亂碼
1 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2.jsp 亂碼
頁面開頭加入
<%@ page language="java" import="java.util.*" contentType ="text/html; charset=utf-8" pageEncoding="utf-8"%>
3.xmlHttpRequest 亂碼
<%@ page contentType ="text/html;charset=GBK"%>
4.Servlet 亂碼
在方法中 加入這兩句
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
5.中文註釋亂碼
原因:Eclipse中對Text file encoding的預設編碼是GBK
解決:
Eclipse->右擊"工程",將Info中的"Text file encoding"中的Other改為UTF-8
MyEclipse ->pro -> Text file encoding ->Other utf-8