【正文】
* selectEncoding() method is set. If set to false, * selectEncoding() is called only if the * client has not already specified an encoding. By default, this * parameter is set to true. * * Although this filter can be used unchanged, it is also easy to * subclass it and make the selectEncoding() method more * intelligent about what encoding to choose, based on characteristics of * the ining request (such as the values of the AcceptLanguage * and UserAgent headers, or a value stashed in the current * user39。s session. */ public class SetEncodingFilter 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 /** * Place this filter into service. * * @param filterConfig The filter configuration object */ public void init(FilterConfig filterConfig) throws ServletException { = filterConfig。 = (encoding)。 String value = (ignore)。 if (value == null) = true。 else if ((true)) = true。 else if ((yes)) = true。 else = false。 } /** * Select and set (if specified) the character encoding to be used to * interpret request parameters for this request. * * @param request The servlet request we are processing * @param result The servlet response we are creating * @param chain The filter chain we are processing * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ (utf8)。 (utf8)。 (request, response)。 } /** * Take this filter out of service. */ public void destroy() { = null。 = null。 } // Protected Methods }本文來自CSDN博客,轉載請標明出處:23 /