Before the text, describe the role of the filter:
Filters, as the name implies, can be implemented and preprocessed by the code.
Popular point of view filter equivalent to the gas station, request is a road, response is a road, the destination is the servlet, where the gas station is located where the data operation can be controlled by you.
Note: Filters can be pre-processed before request and response, effectively filter out unwanted content, and filter can be reused, saving a lot of reuse code, improve Java code execution efficiency
Java controller layer receives the app request, the request parameter is Chinese, the server side received is garbled, how to solve the problem?
Workaround: Add the following configuration in Web. config:
<Filter> <Filter-name>Encodingfilter</Filter-name> <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class> <Init-param> <Param-name>Forceencoding</Param-name> <Param-value>True</Param-value> </Init-param> <Init-param> <Param-name>Encoding</Param-name> <Param-value>UTF-8</Param-value> </Init-param> </Filter> <filter-mapping> <Filter-name>Encodingfilter</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping>
SPRING+MVC controller layer receives the application side request the Chinese parameter garbled question.