Add the spring UTF-8 filter to the Web. xml file.

Source: Internet
Author: User

<? XML version = "1.0" encoding = "UTF-8"?>

<Web-app xmlns = "http://java.sun.com/xml/ns/javaee"

Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.5"

Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee

Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>

<Filter>

// Use spring characterencodingfilter

<Filter-Name> encodingfilter </filter-Name>

<Filter-class>

Org. springframework. Web. Filter. characterencodingfilter

</Filter-class>

<Init-param>

<Param-Name> encoding </param-Name>

// The UTF-8 encoding is used after the filter is filtered.

<Param-value> UTF-8 </param-value>

</Init-param>

</Filter>

<Filter-mapping>

// Filter all paths:/* indicates all paths

<Filter-Name> encodingfilter </filter-Name>

<URL-pattern>/* </url-pattern>

</Filter-mapping>

<Servlet>

<Servlet-Name> action </servlet-Name>

// Actionservlet in struts. All request responses are handled by actionservlet

<Servlet-class>

Org. Apache. Struts. Action. actionservlet

</Servlet-class>

<Init-param>

// Location of the configuration file in struts

<Param-Name> config </param-Name>

<Param-value>/WEB-INF/struts-config.xml </param-value>

</Init-param>

<Init-param>

<Param-Name> debug </param-Name>

<Param-value> 3 </param-value>

</Init-param>

<Init-param>

<Param-Name> detail </param-Name>

<Param-value> 3 </param-value>

</Init-param>

<Load-on-startup> 0 </load-on-startup>

</Servlet>

<Servlet-mapping>

// Name of the mapped suffix Extension

<Servlet-Name> action </servlet-Name>

<URL-pattern> *. DO </url-pattern>

</Servlet-mapping>

<Welcome-file-List>

<Welcome-File> index. jsp </welcome-File>

</Welcome-file-List>

</Web-app>

The Org. springframework. Web. Filter. characterencodingfilter class is unique to spring and specifically solves the problem of UTF-8 garbled Chinese Web.

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.