<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)  編輯  收藏 所屬分類: Java 、Jsp
    主站蜘蛛池模板: 免费国产怡红院在线观看| 国外成人免费高清激情视频| 久久久久亚洲精品男人的天堂| 久久亚洲精品无码网站| 国产精品无码一二区免费| 亚洲大尺度无码无码专线一区| 成年人网站在线免费观看| 亚洲综合色一区二区三区| 国产精品成人免费一区二区 | 国产亚洲精久久久久久无码| 精品人妻系列无码人妻免费视频 | 亚洲国产精品无码AAA片| 国产精品网站在线观看免费传媒| 亚洲国产一成人久久精品| 污污网站免费观看| 亚洲免费福利在线视频| 国产精品深夜福利免费观看| 未满十八私人高清免费影院| 亚洲成a人片77777kkkk| 19禁啪啪无遮挡免费网站| 亚洲欧美日韩综合俺去了| 亚洲日本中文字幕一区二区三区| 国产色无码精品视频免费| 亚洲精品在线免费看| 日本高清免费不卡在线| 久久99久久成人免费播放| 久久精品国产亚洲AV大全| 免费看香港一级毛片| 黄床大片免费30分钟国产精品 | 香港a毛片免费观看| 亚洲精品免费网站| 亚洲国产精品日韩| 99精品视频在线视频免费观看| 亚洲中文字幕乱码熟女在线| 亚洲成a人无码av波多野按摩 | 久久精品国产亚洲AV电影网| 国产亚洲精品AA片在线观看不加载| 亚洲精品视频在线免费| 国产产在线精品亚洲AAVV| 久久精品国产亚洲AV麻豆~| 蜜桃精品免费久久久久影院|