⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysfilter.java

📁 实现类似google 百度的搜索下拉功能
💻 JAVA
字号:
package com.kenshin.base;    
   
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 org.apache.commons.logging.Log;     
import org.apache.commons.logging.LogFactory;    
import org.hibernate.Session;    
import org.hibernate.SessionFactory;    
import org.hibernate.Transaction;     
    
public class SysFilter implements Filter {    
    protected String sEncodingName;    
   
    protected FilterConfig sysFilter;    
   
    protected boolean bEnable;    
   
    protected Log logger = LogFactory.getLog(SysFilter.class);    
   
    public void destroy() {    
   
    }    
   
    public void doFilter(ServletRequest arg0, ServletResponse arg1,    
            FilterChain arg2) throws IOException, ServletException {    
        // TODO Auto-generated method stub    
        if (this.bEnable) {    
            try {      
                arg0.setCharacterEncoding(this.sEncodingName);    
                arg1.setContentType("text/html;charset=" + this.sEncodingName);    
                arg1.setCharacterEncoding(this.sEncodingName);    
                arg2.doFilter(arg0, arg1);    
                logger.info("OK!");   
            } catch (Exception e) {    
                logger.info("�����");    
            }    
            // session.close();    
        } else {    
            arg2.doFilter(arg0, arg1);    
        }    
    }    
   
    public void init(FilterConfig arg0) throws ServletException {    
        // TODO Auto-generated method stub    
        this.sysFilter = arg0;    
        this.loadFilterSetting();    
    }    
   
    private void loadFilterSetting() {    
        this.sEncodingName = this.sysFilter.getInitParameter("encoding");    
        logger.info("encoding:" + sEncodingName);    
        String sEnable = this.sysFilter.getInitParameter("enable");    
        if (sEnable != null && sEnable.equalsIgnoreCase("true")) {    
            this.bEnable = true;    
        } else {    
            this.bEnable = false;    
        }    
    }    
   
   
}  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -