在 doGet() 方法裡面加入以下程式碼,即可將 Servlet 設置為 UTF-8 編碼,理所當然也可以顯示中文:

 

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


// 如果是接收參數的亂碼,請參考以下:

String name = new String(request.getParameter("name").getBytes("iso-8859-1"), "UTF-8");


祝好運~

 

 

 

arrow
arrow
    全站熱搜

    黃彥霖 發表在 痞客邦 留言(0) 人氣()