@Component public class SetCharacterEncodingFilter extends Object implements javax.servlet.Filter
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:
ignore initialization parameter. This parameter
is required, so there is no default.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.
| 构造器和说明 |
|---|
SetCharacterEncodingFilter() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
Select and set (if specified) the character encoding to be used to
interpret request parameters for this request.
|
String |
getEncoding() |
void |
init(javax.servlet.FilterConfig filterConfig) |
boolean |
isIgnore() |
protected String |
selectEncoding(javax.servlet.ServletRequest request)
Select an appropriate character encoding to be used, based on the
characteristics of the current request and/or filter initialization
parameters.
|
void |
setEncoding(String encoding) |
void |
setIgnore(boolean ignore) |
public void setEncoding(String encoding)
public String getEncoding()
public void setIgnore(boolean ignore)
public boolean isIgnore()
public void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter 在接口中 javax.servlet.Filterrequest - The servlet request we are processingresponse - The servlet response we are creatingchain - The filter chain we are processingIOException - if an input/output error occursjavax.servlet.ServletException - if a servlet error occursprotected String selectEncoding(javax.servlet.ServletRequest request)
null.
The default implementation unconditionally returns the value configured by the encoding initialization parameter for this filter.
request - The servlet request we are processingpublic void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init 在接口中 javax.servlet.Filterjavax.servlet.ServletExceptionpublic void destroy()
destroy 在接口中 javax.servlet.FilterCopyright © 2013–2014 Shark Xu. All rights reserved.