用<jsp:include></jsp:include>标签包含一个HTML文件,显示乱码的终极解决办法:
在web.xml里面放入这串代码:
1 <!-- 控制jsp:include的编码为utf-8 --> 2 <jsp-config> 3 <jsp-property-group> 4 <description></description> 5 <display-name>JSPConfiguration</display-name> 6 <url-pattern>*.html</url-pattern> 7 <el-ignored>true</el-ignored> 8 <page-encoding>UTF-8</page-encoding> 9 <scripting-invalid>false</scripting-invalid> 10 <include-prelude></include-prelude> 11 <include-coda></include-coda> 12 </jsp-property-group> 13 </jsp-config>
这样,限制所有的页面为utf-8了,完全解决jsp乱码问题。