Solution to JSP include garbled Problem

Source: Internet
Author: User
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.
 

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.