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错误

解决方案 »

  1.   

    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
    <!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编码保存。
      

  2.   

    还有为什么<%@ include file="text.html"%>导入text.html文件
    <%for(int i=1;i<=3;i++){%>
    <H<%=i%>>大家好才是真的好!!</H<%=i%>><br>
    <%}%>
    时页面显示乱码
      

  3.   

    使用:<jsp:include flush="true" page="text.html"/>导入html文件,这是tomcat的版本问题。tomcat4不会出现乱码。jsp页面注意加入:<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
      

  4.   

    lz用 <jsp:include flush="true" page="hello.txt" /> 还是乱码?
      

  5.   

    因为你写的gb2312,txt文件是什么格式的忘了,反正不是GB2312,你换成一样的就行了,或者转一下TXT文件的格式,转成GB2312就行了
      

  6.   

    回javaboy2006(喝着coffee学java)老师:不乱。我只是不明白为什么用<%@include file="hello.txt"%>不显示中文,英文文本可以显示
      

  7.   

    <%@ include file="hello.txt"%>中文乱码好象是tomcat的版本问题,tomcat4不会出现乱码。
    包括<%@ include file="aaa.html"%>这样使用,如果aaa.html页面中包含中文也会是乱码。
    lz以后使用<jsp:include flush="true" page="hello.txt" /> 就可以了。或者用<%@ include file="hello.txt"%>时文件里不要出现中文。另外,可千万别再叫我老师,不然在CSDN上被人骂死了    :-)