jsp中include静态文件时乱码解决方法

在jsp中include静态文件如html时,显示乱码的解决方法是:

1. 确认jsp的头部编码有

<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8" %>

 2. 在工程的web.xml中增加

<jsp-config>
        <jsp-property-group>
            <description>jsp encoding 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>html encoding 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>

 即可解决html的乱码。

你可能感兴趣的:(include)