亂碼轉碼問題

          convert(username, "ISO8850-1","GBK")
          convert(username, 
          "ISO8850-1","ISO8850-1")
          public static String convert(String src, String decoding, String encoding) {
                  
          if(src == null || decoding == null || encoding == null)
                      
          return null;

                  
          if(decoding.equals(encoding))
                      
          return src;

                  String rs 
          = null;
                  
          try {
                      
          byte[] tb = src.getBytes(decoding);
                      rs 
          = new String(tb, 0, tb.length, encoding);
                  }
           catch (UnsupportedEncodingException e) {
                      rs 
          = src;
                  }


                  
          return rs;
          或者:String username 
          =new String(request.getParameter("username").getBytes("iso8859-1"),"gbk");

          posted on 2012-10-11 14:53 youngturk 閱讀(422) 評論(0)  編輯  收藏 所屬分類: JSP隨筆Java基礎

          <2012年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導航

          統計

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結構
          4 口語英語

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學習

          Flex學習

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 镶黄旗| 桦南县| 柞水县| 屯昌县| 依兰县| 龙游县| 琼中| 平武县| 兴山县| 罗山县| 昌图县| 迭部县| 页游| 类乌齐县| 当雄县| 浏阳市| 自贡市| 甘南县| 揭东县| 丹阳市| 阆中市| 米易县| 深泽县| 龙川县| 美姑县| 邮箱| 平阳县| 临泉县| 屏山县| 洛隆县| 台北市| 平乐县| 德令哈市| 准格尔旗| 五寨县| 米脂县| 玉田县| 个旧市| 漳平市| 广昌县| 深泽县|