Servlet Filter that allows one to specify a character encoding for requests.
This is useful because current browsers typically do not set a character
encoding even if specified in the HTML page or form.
This filter can either apply its encoding if the request does not already
specify an encoding, or enforce this filter's encoding in any case
("forceEncoding"="true"). In the latter case, the encoding will also be
applied as default response encoding (although this will usually be overridden
by a full content type set in the view).
Whether this encoding will override existing request encodings
(and whether it will be applied as default response encoding as well)
depends on the "forceEncoding" flag.
Return the configured encoding for requests and/or responses.
Since:
4.3
setForceEncoding
public void setForceEncoding(boolean forceEncoding)
Set whether the configured encoding of this filter
is supposed to override existing request and response encodings.
Default is "false", i.e. do not modify the encoding if
ServletRequest.getCharacterEncoding()
returns a non-null value. Switch this to "true" to enforce the specified
encoding in any case, applying it as default response encoding as well.
public void setForceRequestEncoding(boolean forceRequestEncoding)
Set whether the configured encoding of this filter
is supposed to override existing request encodings.
Default is "false", i.e. do not modify the encoding if
ServletRequest.getCharacterEncoding()
returns a non-null value. Switch this to "true" to enforce the specified
encoding in any case.
Since:
4.3
isForceRequestEncoding
public boolean isForceRequestEncoding()
Return whether the encoding should be forced on requests.
Since:
4.3
setForceResponseEncoding
public void setForceResponseEncoding(boolean forceResponseEncoding)
Set whether the configured encoding of this filter
is supposed to override existing response encodings.
Default is "false", i.e. do not modify the encoding.
Switch this to "true" to enforce the specified encoding
for responses in any case.
Since:
4.3
isForceResponseEncoding
public boolean isForceResponseEncoding()
Return whether the encoding should be forced on responses.