首页>代码>java交易撮合系统>/jych20080919/webpk/src/conn/SetCharacterEncodingFilter.java
package conn;

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;     
  
public class SetCharacterEncodingFilter   implements   Filter   {     
    protected   String   encoding   =   null;     
      protected   FilterConfig   filterConfig   =   null;     
      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   {     
      //   Conditionally   select   and   set   the   character   encoding   to   be   used     
      if   (ignore   ||   (request.getCharacterEncoding()   ==   null))   {     
      String   encoding   =   selectEncoding(request);     
      if   (encoding   !=   null){     
          System.out.println(encoding+" 11111111111111111111111");     
      request.setCharacterEncoding(encoding);     
      }     
      System.out.println("Null");     
      }     
      //   Pass   control   on   to   the   next   filter     
      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;     
  
      }     
      protected   String   selectEncoding(ServletRequest   request)   {     
      return   (this.encoding);     
      }     
} 
最近下载更多
li739784276  LV5 2022年8月16日
男波one  LV1 2022年5月10日
skook7  LV2 2022年4月29日
微信网友_5847813140320256  LV1 2022年2月25日
李拾壹  LV5 2022年1月2日
explorerwx  LV2 2021年10月2日
刘晴天  LV1 2021年5月6日
xxpphh  LV1 2021年3月17日
王伟杰  LV2 2021年1月6日
乔鹿野  LV6 2020年12月23日
最近浏览更多
做自己的太阳  LV11 前天
2206371875  LV7 3月14日
try8023  LV18 1月16日
微信网友_6641066057273344  LV1 2023年10月27日
520131  LV5 2023年7月1日
1613619109  LV6 2023年3月25日
我是超爱学习 2023年2月28日
暂无贡献等级
fantesy  LV17 2023年1月16日
103463  LV1 2022年12月5日
yangylh  LV1 2022年11月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友