亂碼轉碼問題

          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

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 漾濞| 陈巴尔虎旗| 资溪县| 恩施市| 花垣县| 临海市| 红原县| 内丘县| 平阴县| 安乡县| 黄梅县| 平利县| 赤水市| 中西区| 尼玛县| 大方县| 鲁山县| 郴州市| 如东县| 宣化县| 简阳市| 祁东县| 拜泉县| 浪卡子县| 深水埗区| 洞口县| 墨玉县| 招远市| 亚东县| 伊金霍洛旗| 庆云县| 峨边| 通山县| 玛曲县| 翁牛特旗| 老河口市| 个旧市| 太白县| 永善县| 墨脱县| 江达县|