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

📄 setcharacterencoding.java

📁 一个完整的门户网站,基于JSP环境下开发的,使用SQL数据库.
💻 JAVA
字号:
package com.bwm.core;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.FilterChain;import java.io.IOException;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: MR</p> * @author BWM * @version 1.0 */public class SetCharacterEncoding {    public SetCharacterEncoding() {    }    protected String encoding = null;    protected FilterConfig filterConfig = null;    public void init(FilterConfig filterConfig) throws ServletException {        /**@todo Implement this javax.servlet.Filter method*/        this.filterConfig=filterConfig;        this.encoding=filterConfig.getInitParameter("encoding");    }    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {        /**@todo Implement this javax.servlet.Filter method*/       String encoding=selectEncoding(request);        if(encoding!=null)            request.setCharacterEncoding(encoding);        chain.doFilter(request,response);    }    public void destroy() {        /**@todo Implement this javax.servlet.Filter method*/        this.encoding=null;        this.filterConfig=null;    }    protected String selectEncoding(ServletRequest request) {        return (this.encoding);    }}

⌨️ 快捷键说明

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