<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无码乱码国产麻豆穿越| 嫩草影院免费观看| 国内精品久久久久久久亚洲| 亚洲AV无码一区二区三区网址| 国产91免费在线观看| 亚洲综合久久久久久中文字幕| 3344在线看片免费| 亚洲大尺度无码专区尤物| 99视频在线免费观看| 亚洲精品白浆高清久久久久久| 国产人成网在线播放VA免费| 国产美女亚洲精品久久久综合| 人碰人碰人成人免费视频| 久久亚洲精品无码观看不卡| 好男人资源在线WWW免费| 亚洲av永久无码精品漫画 | 国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 | 亚洲免费电影网站| 久久久久精品国产亚洲AV无码| 野花高清在线电影观看免费视频| 33333在线亚洲| 国产一级大片免费看| 亚洲免费视频一区二区三区| 国产精品亚洲片在线| **一级毛片免费完整视| 亚洲色图激情文学| 国产免费看插插插视频| 国产精品一区二区三区免费| 图图资源网亚洲综合网站| 日本XXX黄区免费看| 日韩亚洲综合精品国产| 亚洲人成网亚洲欧洲无码久久| 久久国产免费观看精品3| 亚洲人AV在线无码影院观看| 亚洲国产人成精品| 午夜精品一区二区三区免费视频| 亚洲国产精品一区二区久| 日韩免费无砖专区2020狼| 99视频在线观看免费| 亚洲色欲色欱wwW在线| 亚洲自偷自偷偷色无码中文|