类 CharacterEncodingFilter
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.beans.factory.DisposableBean,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.EnvironmentAware,cn.taketoday.core.env.EnvironmentCapable,ServletContextAware,Filter
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).
- 从以下版本开始:
- 4.0 2023/4/2 16:02
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
字段从类继承的字段 cn.taketoday.web.servlet.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX从类继承的字段 cn.taketoday.web.servlet.filter.GenericFilterBean
logger -
构造器概要
构造器构造器说明Create a defaultCharacterEncodingFilter, with the encoding to be set viasetEncoding(java.lang.String).CharacterEncodingFilter(String encoding) Create aCharacterEncodingFilterfor the given encoding.CharacterEncodingFilter(String encoding, boolean forceEncoding) Create aCharacterEncodingFilterfor the given encoding.CharacterEncodingFilter(String encoding, boolean forceRequestEncoding, boolean forceResponseEncoding) Create aCharacterEncodingFilterfor the given encoding. -
方法概要
修饰符和类型方法说明protected voiddoFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) Same contract as fordoFilter, but guaranteed to be just invoked once per request within a single request thread.Return the configured encoding for requests and/or responses.booleanReturn whether the encoding should be forced on requests.booleanReturn whether the encoding should be forced on responses.voidsetEncoding(String encoding) Set the encoding to use for requests.voidsetForceEncoding(boolean forceEncoding) Set whether the configuredencodingof this filter is supposed to override existing request and response encodings.voidsetForceRequestEncoding(boolean forceRequestEncoding) Set whether the configuredencodingof this filter is supposed to override existing request encodings.voidsetForceResponseEncoding(boolean forceResponseEncoding) Set whether the configuredencodingof this filter is supposed to override existing response encodings.从类继承的方法 cn.taketoday.web.servlet.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch从类继承的方法 cn.taketoday.web.servlet.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
字段详细资料
-
encoding
-
forceRequestEncoding
private boolean forceRequestEncoding -
forceResponseEncoding
private boolean forceResponseEncoding
-
-
构造器详细资料
-
CharacterEncodingFilter
public CharacterEncodingFilter()Create a defaultCharacterEncodingFilter, with the encoding to be set viasetEncoding(java.lang.String). -
CharacterEncodingFilter
Create aCharacterEncodingFilterfor the given encoding.- 参数:
encoding- the encoding to apply- 另请参阅:
-
CharacterEncodingFilter
Create aCharacterEncodingFilterfor the given encoding.- 参数:
encoding- the encoding to applyforceEncoding- whether the specified encoding is supposed to override existing request and response encodings- 另请参阅:
-
CharacterEncodingFilter
public CharacterEncodingFilter(String encoding, boolean forceRequestEncoding, boolean forceResponseEncoding) Create aCharacterEncodingFilterfor the given encoding.- 参数:
encoding- the encoding to applyforceRequestEncoding- whether the specified encoding is supposed to override existing request encodingsforceResponseEncoding- whether the specified encoding is supposed to override existing response encodings- 另请参阅:
-
-
方法详细资料
-
setEncoding
Set the encoding to use for requests. This encoding will be passed into aServletRequest.setCharacterEncoding(java.lang.String)call.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. -
getEncoding
Return the configured encoding for requests and/or responses. -
setForceEncoding
public void setForceEncoding(boolean forceEncoding) Set whether the configuredencodingof 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.This is the equivalent to setting both
setForceRequestEncoding(boolean)andsetForceResponseEncoding(boolean). -
setForceRequestEncoding
public void setForceRequestEncoding(boolean forceRequestEncoding) Set whether the configuredencodingof 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. -
isForceRequestEncoding
public boolean isForceRequestEncoding()Return whether the encoding should be forced on requests. -
setForceResponseEncoding
public void setForceResponseEncoding(boolean forceResponseEncoding) Set whether the configuredencodingof 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.
-
isForceResponseEncoding
public boolean isForceResponseEncoding()Return whether the encoding should be forced on responses. -
doFilterInternal
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException 从类复制的说明:OncePerRequestFilterSame contract as fordoFilter, but guaranteed to be just invoked once per request within a single request thread. SeeOncePerRequestFilter.shouldNotFilterAsyncDispatch()for details.Provides HttpServletRequest and HttpServletResponse arguments instead of the default ServletRequest and ServletResponse ones.
- 指定者:
doFilterInternal在类中OncePerRequestFilter- 抛出:
ServletExceptionIOException
-