SPRING+MVC controller layer receives the application side request the Chinese parameter garbled question.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.