有時候一個小疏忽,付出的代價就是要抓蟲抓半天....
網頁最常遇到就是亂碼的問題,java要取得正確的編碼,有幾個地方要設對
1. in jsp, use pageEncoding to set the response character encoding.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
2. in html, set the charset attribute of the HTTP Content-Type header.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
3. 再來就是透過ServletRequest#setCharacterEncoding來解決server端decode的問題。且最重要的是setCharacterEncoding要在讀取request parameter前就設定,否則無效。

一時的虧手,不小心加了getParameter在網頁最上面,亂碼就出現了.........

arrow
arrow
    全站熱搜

    mark528 發表在 痞客邦 留言(0) 人氣()