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

帮我看看这个JSP中乱码怎么解决?
loc.jsp
<%@page   contentType= "text/html;charset=gb2312 "%>
<%@include   file= "top.txt "%>
<p   align= "center ">
  <%out.println( "此书出版了,快来看看吧!还有更多的好书等着您呢! ");%>
</p>
<%@include   file= "bottom.txt "%>

top.txt

<html>
<head>
<title> 《JSP从入门到实战》网站 </title>
</head>
<body>
<p   align= "center "> <b> <font   size= "5 "> 《JSP从入门到实战》网站 </font> </b> </p>

bottom.txt

<hr>
<p   align= "center ">
<font   size= "3 "> @电子工业出版社版权所有   2004-2008 </font> <br>  
<font   size= "3 "> 制作人:邓子云 </font> <br>
<font   size= "3 "> 联系方式:dengziyun@126.com </font> <br>
</body>
</html>

文件中bottom.txt和top.txt的内容在JSP中乱码,为什么?怎么解决?

------解决方案--------------------
在前面加入 <%request.setCharacterEncoding( "GB2312 ") ;%> 试试,建议把txt写成jsp的吧,在页面里也加上 <%@ page contentType= "text/html; charset=GB2312 " %> 。JSP很久不用了,不知道能不能解决~表见怪……