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

📄 filteroflanguage.java~5~

📁 基于mvc的宠物管理系统。servlet+jsp
💻 JAVA~5~
字号:
package com.richard.dao;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class FilterOfLanguage extends HttpServlet implements Filter {
    private FilterConfig filterConfig;
    protected String encoding = null;

    protected boolean ignore = true;

    //Handle the passed-in FilterConfig
    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    //Process the request/response pair
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain filterChain) {
        try {

            if (ignore || (request.getCharacterEncoding() == null)) {
                String encoding = selectEncoding(request);
                if (encoding != null) {
                    System.out.println(encoding);
                    request.setCharacterEncoding(encoding);
                }
                System.out.println("Null");
            }

            filterChain.doFilter(request, response);

        } catch (ServletException sx) {
            filterConfig.getServletContext().log(sx.getMessage());
        } catch (IOException iox) {
            filterConfig.getServletContext().log(iox.getMessage());
        }
    }

    protected String selectEncoding(ServletRequest request) {
        return (this.encoding);
    }

    //Clean up resources
    public void destroy() {
        this.encoding = null;
        this.filterConfig = null;
    }
}

⌨️ 快捷键说明

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