include.jsp:
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>JSP include范例</title>
</head>
<body>
<h4>
<%@ include file="hello.txt"%>
</h3>
</body>
</htmlhello.txt:
这是一个插入文本的例子为什么出现Include.jsp(8,0) Invalid byte 2 of 2-byte UTF-8 sequence错误
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>JSP include范例</title>
</head>
<body>
<h4>
<%@ include file="hello.txt"%>
</h3>
</body>
</htmlhello.txt:
这是一个插入文本的例子为什么出现Include.jsp(8,0) Invalid byte 2 of 2-byte UTF-8 sequence错误
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>JSP include范例</title>
</head>
<body>
<h4>
<%@ include file="hello.txt"%>
<jsp:include flush="true" page="hello.txt"/>
</h4>
</body>
</html>hello.txt用ANSI编码保存。
<%for(int i=1;i<=3;i++){%>
<H<%=i%>>大家好才是真的好!!</H<%=i%>><br>
<%}%>
时页面显示乱码
包括<%@ include file="aaa.html"%>这样使用,如果aaa.html页面中包含中文也会是乱码。
lz以后使用<jsp:include flush="true" page="hello.txt" /> 就可以了。或者用<%@ include file="hello.txt"%>时文件里不要出现中文。另外,可千万别再叫我老师,不然在CSDN上被人骂死了 :-)