這個問題比較老了,但是網(wǎng)上的案例太少。自己做個記號
          兩個頁面a.jsp,b.jsp。一個發(fā),一個收。
          a.jsp
           1<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
           2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           3<html xmlns="http://www.w3.org/1999/xhtml">
           4<head>
           5<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
           6<title>A</title>
           7</head>
           8 
           9<body>
          10<% 
          11       String str_test = "中文";
          12
          %>
          13<form method=post action="b.jsp?test=<%=java.net.URLEncoder.encode(str_test) %>"> 
          14         <input type="submit" value="按鈕1">   
          15 </form>
          16 
          17 <form method=post action="b.jsp?test=<%=str_test %>"> 
          18         <input type="submit" value="按鈕2">   
          19 </form>
          20 
          21</body>
          22</html>
          23

          b.jsp
           1<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
           2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           3<html xmlns="http://www.w3.org/1999/xhtml">
           4<head><title>B</title></head>
           5 
           6<body>
           7 
           8<% 
           9       String str = new String(request.getParameter("test").getBytes("ISO8859_1"));
          10
          %> 
          11 <BR>
          12 <%=str %> 
          13 <BR>
          14 <% 
          15       String str1 = new String(request.getParameter("test").getBytes("ISO8859_1"),"gb2312");
          16
          %> 
          17 <BR>
          18 <%=str1 %>
          19
          20</body>
          21</html>
          22

          運行a.jsp,點擊按鈕1.

          提交到b.jsp。

          如果直接傳中文呢?點擊按鈕2.


          結(jié)果:

          關(guān)鍵的問題在于每個頁面中的 charset=gb2312;這個是頁面顯示中文的關(guān)鍵

          posted on 2007-12-07 12:27 湘江夜游神 閱讀(794) 評論(0)  編輯  收藏 所屬分類: JSP

          Locations of visitors to this page

          主站蜘蛛池模板: 类乌齐县| 巴东县| 建水县| 运城市| 城固县| 天镇县| 淳安县| 镇安县| 昌乐县| 武定县| 高台县| 平顺县| 宽城| 土默特右旗| 视频| 广灵县| 武山县| 攀枝花市| 武功县| 洪雅县| 高唐县| 塘沽区| 华阴市| 武平县| 东乡族自治县| 汾阳市| 井研县| 孟连| 安丘市| 扶风县| 天长市| 阜康市| 沂源县| 湘潭市| 甘谷县| 库尔勒市| 绥滨县| 滁州市| 永嘉县| 嘉善县| 临汾市|