The Ajax or get Chinese Characters in Tomcat and WebLogic are garbled

Source: Internet
Author: User

This method ensures that no garbled characters are generated in Tomcat and weblogic.

1. <connector Port = "8080" protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443"Uriencoding = "UTF-8 "/>

Change Tomcat encoding, Tomcat is iso-8859-1 by default

2. Configure spring encoding in Web. xml

<Filter>
<Filter-Name> encodingfilter </filter-Name>
<Filter-class> org. springframework. Web. Filter. characterencodingfilter </filter-class>
<Init-param>
<Param-Name> encoding </param-Name>
<Param-value> UTF-8 </param-value>
</Init-param>
<Init-param>
<Param-Name> forceencoding </param-Name>
<Param-value> true </param-value>
</Init-param>
</Filter>

3. jsp

Encodeuri (URL)

4. Action:

CompanyName = java.net. urldecoder. Decode (request. getparameter ("companyName"), "UTF-8 ");
Or directly obtain
CompanyName = request. getparameter ("companyName ");

In this way, the deployment to WebLogic does not contain garbled characters, and you do not need to set the encoding in the filter.

Release to WebLogic put the spring configuration file under/WEB-INF/, otherwise it will not be found

Related Article

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.