<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 431,  comments - 344,  trackbacks - 0

    import Java.io.IOException;

    import javax.servlet.Filter;

    import javax.servlet.FilterChain;

    import javax.servlet.FilterConfig;

    import javax.servlet.ServletException;

    import javax.servlet.ServletRequest;

    import javax.servlet.ServletResponse;

    import javax.servlet.UnavailableException;

    public class SetCharacterEncodingFilter implements Filter {

        /**    

          * The default character encoding to set for requests that pass through this filter.    

          */

           protected String encoding=null;

           /**    

             * The filter configuration object we are associated with.  If this value    

             * is null, this filter instance is not currently configured.    

             */

           protected FilterConfig filterConfig=null;

        /**    

          * Should a character encoding specified by the client be ignored?    

          */

           protected boolean ignore=true;

          

           public void destroy()

           {

                  this.encoding=null;

                  this.filterConfig=null;

           }

           public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain)throws IOException,ServletException

           {

                  if(ignore||(request.getCharacterEncoding()==null))

                  {

                         String encoding=selectEncoding(request);

                         if(encoding!=null)

                                request.setCharacterEncoding(encoding);

                  }

                  chain.doFilter(request,response);

           }

           public void init(FilterConfig filterConfig)throws ServletException

           {

                  this.filterConfig=filterConfig;

                  this.encoding=filterConfig.getInitParameter("encoding");

                  String value=filterConfig.getInitParameter("ignore");

                  if(value==null)

                         this.ignore=true;

                  else if(value.equalsIgnoreCase("true"))

                         this.ignore=true;

                  else if(value.equalsIgnoreCase("yes"))

                         this.ignore=true;

                  else

                         this.ignore=false;

           }

           private String selectEncoding(ServletRequest request) {

                  return (this.encoding);

           }

    }

    web.xml 文件里添加

    <filter>

          <filter-name>Set Character Encoding</filter-name>

          <filter-class>com.netmarch.struts.filters.SetCharacterEncodingFilter</filter-class>

          <init-param>

             <param-name>encoding</param-name>

             <param-value>UTF-8</param-value>

          </init-param>

      </filter>

      <filter-mapping>

          <filter-name>Set Character Encoding</filter-name>

          <url-pattern>/*</url-pattern>

      </filter-mapping>
    posted on 2006-09-04 16:32 周銳 閱讀(156) 評論(0)  編輯  收藏 所屬分類: JavaJsp
    主站蜘蛛池模板: 亚洲AV永久纯肉无码精品动漫| 亚洲夂夂婷婷色拍WW47| 亚洲精品福利视频| 亚洲中文字幕精品久久| 国内精品乱码卡1卡2卡3免费| 亚洲福利精品一区二区三区| 亚洲美免无码中文字幕在线| 免费一级特黄特色大片| 国产精品69白浆在线观看免费| 亚洲三区在线观看无套内射| 国产精品国产亚洲区艳妇糸列短篇| 一级成人a毛片免费播放| 亚洲男人的天堂在线va拉文| 亚洲一区欧洲一区| 美女被cao网站免费看在线看| 免费观看国产小粉嫩喷水| 国产成人亚洲综合网站不卡| 84pao国产成视频免费播放| 久久精品亚洲男人的天堂| 亚洲国产高清国产拍精品| 国色精品卡一卡2卡3卡4卡免费| 亚洲中文字幕无码av| 亚洲日韩精品无码专区网站| 国产精品亚洲一区二区麻豆| 日韩精品电影一区亚洲| 亚洲AV无码精品国产成人| 无码一区二区三区免费视频 | 在线观看91精品国产不卡免费| 666精品国产精品亚洲| 日韩免费a级毛片无码a∨| 午夜亚洲国产理论片二级港台二级| 亚洲无线一二三四区手机| 久久永久免费人妻精品下载| 狠狠亚洲婷婷综合色香五月排名| 美美女高清毛片视频黄的一免费| 免费看a级黄色片| 亚洲GV天堂GV无码男同| 中文字幕亚洲一区| 免费三级毛片电影片| 四虎精品免费永久免费视频| 亚洲成?Ⅴ人在线观看无码|