Class SetCharacterEncodingFilter

All Implemented Interfaces:

public class SetCharacterEncodingFilter extends FilterBase

Example filter that sets the character encoding to be used in parsing the incoming request, either unconditionally or only if the client did not specify a character encoding. Configuration of this filter is based on the following initialization parameters:

  • encoding - The character encoding to be configured for this request, either conditionally or unconditionally based on the ignore initialization parameter. This parameter is required, so there is no default.
  • ignore - If set to "true", any character encoding specified by the client is ignored, and the value returned by the 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 "false".

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 incoming request (such as the values of the Accept-Language and User-Agent headers, or a value stashed in the current user's session.