<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 周銳 閱讀(153) 評論(0)  編輯  收藏 所屬分類: JavaJsp
    主站蜘蛛池模板: 亚洲成年网站在线观看| 国产大片免费天天看| 免费人成视频在线观看视频| 皇色在线免费视频| 亚洲欧洲久久精品| 四虎影视永久免费视频观看| 中文字幕无码日韩专区免费| 亚洲一卡2卡4卡5卡6卡残暴在线| 国产免费牲交视频| 精品无码人妻一区二区免费蜜桃| 国产 亚洲 中文在线 字幕 | 精品国产亚洲一区二区三区 | 1000部拍拍拍18勿入免费视频下载| 99热亚洲色精品国产88| 亚洲中文字幕无码爆乳AV| 男人的好免费观看在线视频| 好吊色永久免费视频大全| 午夜在线a亚洲v天堂网2019| 中文字幕人成人乱码亚洲电影| 2020久久精品国产免费| 久久久精品视频免费观看| 亚洲熟妇无码一区二区三区| 亚洲国产日韩一区高清在线| 国产一区视频在线免费观看| 亚洲视频在线免费看| 91视频免费观看高清观看完整| 亚洲综合中文字幕无线码| 亚洲大片在线观看| www.亚洲精品.com| 成人片黄网站色大片免费| a毛片视频免费观看影院| 国产亚洲视频在线观看| 亚洲成a人片在线观看精品| 亚洲av无码专区国产乱码在线观看| 在线观着免费观看国产黄| 四虎永久在线观看免费网站网址| 人妻免费一区二区三区最新| 无码免费又爽又高潮喷水的视频| 亚洲综合精品伊人久久| 亚洲三级在线免费观看| 中文字幕亚洲色图|