天天看點

【已解決】idea編譯器插入資料到資料庫亂碼以及jsp頁面亂碼的解決方法

1.jsp頁面需要設定編碼格式為utf-8

1 <%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="utf-8" %>
2 <%request.setCharacterEncoding("utf-8");%>
3 
4 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">      

2.jsp頁面form表單送出資料方式改為post,為get會有類似英文的亂碼

3.設定項目的各種編碼格式,點選左上角Files——>settings,搜尋file encoding,選擇utf-8

【已解決】idea編譯器插入資料到資料庫亂碼以及jsp頁面亂碼的解決方法

4.設定request和response編碼(一定是擷取資料之前)

1 response.setContentType("text/html;charset=utf-8");
2 request.setCharacterEncoding("utf-8");
3 response.setCharacterEncoding("utf-8");      

5.設定資料庫字元集

【已解決】idea編譯器插入資料到資料庫亂碼以及jsp頁面亂碼的解決方法

 6.檢查tomcat字元集

 添加tomcat伺服器時,在VM中添加&characterEncoding=UTF-8,然後apply

【已解決】idea編譯器插入資料到資料庫亂碼以及jsp頁面亂碼的解決方法

 轉載自:https://www.yht7.com/news/5449

繼續閱讀