java學習

          java學習

           

          中文字符轉碼

          1.    String s = “中文”;
          S = new String(s.getBytes(“ISO8859-1”),”utf-9”);
          2.    使用過濾器:
          public class CharsetFilter implements Filter{

              private String encoding = "UTF-8";
              
              public void destroy() {
                  
              }

              public void doFilter(ServletRequest request, ServletResponse response,
                      FilterChain chain) throws IOException, ServletException {
                  request.setCharacterEncoding(encoding);
                  chain.doFilter(request, response);
              }

              public void init(FilterConfig filterConfig) throws ServletException {
                  String encoding = filterConfig.getInitParameter("encoding");
                  if(encoding != null) {
                      this.encoding = encoding;
                  }
              }

          }
          3.request.setCharacterEncoding(“utf-8”);

          posted on 2012-05-04 21:55 楊軍威 閱讀(1936) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 广汉市| 张北县| 禹城市| 新昌县| 琼中| 商水县| 阿克| 长兴县| 西丰县| 西和县| 灵台县| 盐津县| 海丰县| 荆州市| 于都县| 清原| 阿瓦提县| 洱源县| 石首市| 陵川县| 台中县| 富民县| 铁力市| 黄陵县| 萍乡市| 喜德县| 阿荣旗| 德庆县| 安新县| 红河县| 张家川| 方山县| 弋阳县| 田林县| 视频| 太保市| 福贡县| 会宁县| 遵化市| 二连浩特市| 综艺|