Solution to JSP include garbled Problem
JSP include files may sometimes contain garbled characters. The following methods can be modified after testing.
In the first case, you can modify the file to be included:
1. When JSP include dynamic files (JSP files), you can add code to the header of the included JSP file:
<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8" pageencoding = "UTF-8" %>
Yes.
2. When JSP include static files (HTML files), you can add code to the <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
It can also be solved.
In the second case, the file to be included cannot be modified:
In this case, you can modify Tomcat's web. XML for the purpose.
<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.4" xmlns = "http://java.sun.com/xml/ns/j2ee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/j2ee
Http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd>
<JSP-config>
<JSP-property-group>
<Description>
Special Property Group for JSP configuration JSP
Example.
</Description>
<Display-Name> jspconfiguration </display-Name>
<URL-pattern> *. jsp </url-pattern>
<El-ignored> true </El-ignored>
<Page-encoding> UTF-8 </page-encoding>
<Scripting-invalid> false </Scripting-invalid>
<Include-prelude> </include-prelude>
<Include-coda> </include-coda>
<Description>
Special Property Group for JSP configuration JSP
Example.
</Description>
<Display-Name> jspconfiguration </display-Name>
<URL-pattern> *. html </url-pattern>
<El-ignored> true </El-ignored>
<Page-encoding> UTF-8 </page-encoding>
<Scripting-invalid> false </Scripting-invalid>
<Include-prelude> </include-prelude>
<Include-coda> </include-coda>
</JSP-property-group>
</JSP-config>
</Web-app>
The JSP-config section describes the encoding format of the page to be included by default. The version of the web-app tag must be 2.4.