jsp中导入html页面,JSP页面显示html页面内容是乱码
jsp页面:index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<%@ page contentType= "text/html; charset=gb2312 " %>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<%@page pageEncoding= "gb2312 "%>
<title> 测试JSP导入HTML </title>
</head>
<body>
<%@ include file= "inc/tail.htm "%>
</body>
html页面:tail.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
<body>
<table width= "650 " height= "54 " border= "0 " align= "center ">
<tr bgcolor= "#999999 ">
<td height= "1 " colspan= "3 "> </td>
</tr>
<tr>
<td height= "51 "> </td>
<td align= "center " valign= "middle "> <p> <font color= "#009900 " size= "3 "> Copyright:2006-2007 <br>
</font> <font color= "#009900 " size= "3 "> Address:中国 </font> <font color= "#009900 " size= "3 "> Contact:世界 </font> </p> </td>
<td> </td>
</tr>
</table>
</body>
</html>
我和下面这篇文章的情况很相似,但都没有好的解决办法
http://topic.csdn.net/t/20050206/18/3778968.html
我浏览器输入:http://localhost:8888/index.jsp
显示如下:
Copyright:2006-2007
Address:???úContact:????
按理应该输出:
Copyright:2006-2007
Address中国Contact:世界
问题出在哪?知道的请帮忙,多谢各位先了
------解决方案--------------------charset=gb2312 换成charset=8859_1 你试下..
------解决方案--------------------右击选择编码,然后选择简体中文看看
------解决方案--------------------原因是 <%@ include file= "inc/tail.htm "%>
要想正常显示tail这个文件的内容,必须要使其扩展名为jsp
不能使用静态页面的原因是:静态页面没法设置页面编码,即使你再三使用了:
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
只有在Jsp页面内开头设置以下:
<%@page contentType= "text/html;charset=gb2312 "%>
其他静态内容照常就OK拉!