日期:2014-05-18  浏览次数:20606 次

jsp中include指令问题
include.jsp:
<%@   page   contentType= "text/html;charset=gb2312 "%>
<html>
<head>
<title> JSP   include范例 </title>
</head>
<body>
<h4>
<%@   include   file= "hello.txt "%>
</h3>
</body>
</html

hello.txt:
这是一个插入文本的例子

为什么出现Include.jsp(8,0)   Invalid   byte   2   of   2-byte   UTF-8   sequence错误

------解决方案--------------------
<%@ 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编码保存。
------解决方案--------------------
使用: <jsp:include flush= "true " page= "text.html "/> 导入html文件,这是tomcat的版本问题。tomcat4不会出现乱码。

jsp页面注意加入: <%@ page language= "java " import= "java.util.* " pageEncoding= "GBK "%>

------解决方案--------------------
lz用 <jsp:include flush= "true " page= "hello.txt " /> 还是乱码?
------解决方案--------------------
因为你写的gb2312,txt文件是什么格式的忘了,反正不是GB2312,你换成一样的就行了,或者转一下TXT文件的格式,转成GB2312就行了