JSP 編碼設定與應用
以下以 UTF-8 為預設方式
一般情況設定 <Form method="post">
1.網頁檔案儲存為UTF-8 Code方式 (用記事本另存即可)
2.置入程式碼
<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
%>
例外情況
1. 使用 <Form method="get">傳值
2. 使用 JavaScript encodeURIComponent() 編碼傳值
例:window.location='process.jsp?qMsg='+encodeURIComponent(mainF.qMsg.value);