<jsp:include page=“我只能是jsp文件”/>
这样的用法只能是在页面中导入jsp文件.
如果想要导入html文件的话,就可以使用<%@ include file=“html文件”%>
如果出现乱码情况,首先确保jsp和引入的html编码一致,是utf-8的.如果仍然是乱码则是由于pageEncoding设置问题导致翻译jsp时码。有两种方式处理:
方法一:在每个引入的html文件设置pageEncoding编码,即在html添加<%@page pageEncoding=“UTF-8”%>,尽管html不能识别该指令,但通过include指令引入时该指令就能起作用了.
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
文件内容
</body>
</html>
方法二:在web.xml里统一配置pageEncoding的编码,在web-app标签里添加如下配置:
<jsp-config>
<jsp-property-group>
<description>html encoding</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>
转载:https://blog.csdn.net/myth_g/article/details/78991532