JSP include HTML garbled problem solved

Source: Internet
Author: User

Problem?

When you use <jsp:include page= "top.html" ></jsp:include> introduce HTML files,

and the JSP and HTML encoding are utf-8, but there will be garbled,

is to automatically encode HTML when using <jsp:include.

And this code is the system default GBK so at this time and their own code conflicts will appear garbled,

Let's take a look at the configuration of Jsp-config in Web. xml

<jsp-config> includes <taglib> and <jsp-property-group> two child elements.

where the <taglib> element already exists at JSP 1.2;

<jsp-property-group> is the new element in JSP 2.0.

The <jsp-property-group> element consists of eight sub-elements, each of which are:


1.<description>: Description of the setting
2.<display-name>: Set name
3.<URL-PATTERN>: The range affected by the setpoint, such as:/ch2 or/*.jsp
4.<el-ignored>: True to indicate that El syntax is not supported
5.<scripting-invalid>: True to indicate that <% scripting%> syntax is not supported
6.<PAGE-ENCODING>: Setting the encoding of a JSP Web page
7.<include-prelude>: Sets the header of the JSP Web page with the extension. JSPF
8.<INCLUDE-CODA>: Sets the end of the JSP Web page with the extension. JSPF

Answer:

The workaround is to add the following code in Web. XML:

<Jsp-config>     <Jsp-property-group>     <Description>Special Property Group for JSP Configuration HTML 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>

JSP include HTML garbled problem solved

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.