src/com/oa/utils/SetCharacterEncodingFilter.java

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.oa.utils;
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 { 

        // ------------ Instance Variables 

        /** 
         * 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 Methods 

        /** 
         * Take this filter out of service. 
         */ 
        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) 
                                request.setCharacterEncoding(encoding); 
                } 

                // Pass control on to the next filter 
                chain.doFilter(request, response); 

        } 

        public void init(FilterConfig filterConfig) throws ServletException { 

                this.filterConfig = filterConfig; 
后面还有 22 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。