Javascript Chinese garbled characters in ie, and iejs Chinese garbled characters
First common situation
Generally, as long as the jsp and js file encoding formats are consistent, Chinese garbled characters can be solved.
UTF-8 encoding has always been used, including pageEncoding of jsp pages.
<% @ Page language = "java" contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %>
If there is still a garbled problem, you need to consider what the web application server is. I encountered a situation where Chinese characters are garbled in the development environment and no Chinese characters are garbled when deployed to the testing machine, the biggest difference found through repeated tests is that
In the development environment, jetty is used to test tomcat.
In this direction, du Niang finally found the same victim,
Jetty's Chinese problems have never been well implemented by Tomcat, so Chinese garbled characters often occur.
Some experiences of the predecessors are verified, and some differences are found. When comparing Jetty and Tomcat parameters, the Response is found to be inconsistent.
Tomcat Response:
Content-Type application/javascript
Jetty's Response:
Content-Type application/x-javascript; charset = GB2312
This is the Validation result of my monitoring js file (ie)
The final solution is to add a filter 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>
<Filter-mapping>
<Filter-name> encodingFilter </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>
In this way, the response is UTF-8, And the garbled problem is finally solved.